CSES - Datatähti 2024 alku - Results
Submission details
Task:Lumimyrsky
Sender:Vulpesvulpes
Submission time:2023-11-05 21:21:12 +0200
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:18:29: warning: comparison with string literal results in unspecified behavior [-Waddress]
   18 |         if (std::cin.peek() == "\n")
      |             ~~~~~~~~~~~~~~~~^~~~~~~
input/code.cpp:18:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]

Code

#include <iostream>

int main()
{
    int routeElevation[2] = { 0, 0 };
    int i = 0;
    while (i <= 1)
    {
        int num = 0;
        int prevNum = 0;
        std::cin >> num;
        if (num > prevNum)
        {
            routeElevation[i] += num - prevNum;
        }

        prevNum = num;
        if (std::cin.peek() == "\n")
        {
            i++;
        }
    }
    if (routeElevation[1] > routeElevation[0])
    {
        std::cout << 1;
    }
    else
    {
        std::cout << 2;
    }

    return 0;
}