CSES - Datatähti 2024 alku - Results
Submission details
Task:Lumimyrsky
Sender:Akaseli
Submission time:2023-10-30 09:57:38 +0200
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:8:5: error: expected unqualified-id before 'int'
    8 |     int prevB = 0;
      |     ^~~
input/code.cpp:25:14: error: 'prevB' was not declared in this scope; did you mean 'prevA'?
   25 |         if(x-prevB>0){
      |              ^~~~~
      |              prevA
input/code.cpp:28:9: error: 'prevB' was not declared in this scope; did you mean 'prevA'?
   28 |         prevB = x;
      |         ^~~~~
      |         prevA

Code

#include <bits/stdc++.h>

using namespace std;

int main(){
    int prevA = 0,
    int prevB = 0;

    int nousuA = 0;
    int nousuB = 0;

    for(int i = 0; i<10; i++){
        int x;
        cin >> x;
        if(x-prevA>0){
            nousuA += x;
        }
        prevA = x;
    }

    for(int i = 0; i<10; i++){
        int x;
        cin >> x;
        if(x-prevB>0){
            nousuB += x;
        }
        prevB = x;
    }

    if(nousuA<nousuB){
        cout << "1";
    }
    else{
        cout << "2";
    }
}