제출 #1338332

#제출 시각아이디문제언어결과실행 시간메모리
1338332poapaa.Infinite Race (EGOI24_infiniterace2)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

int main() {
    int n, q, diff, maxi;
    cin >> n >> q;
    diff = maxi = 0;
    for( i = 1; i <= q; i++ ) {
        cin >> x;
        if( x > 0 )
            diff++;
        else
            diff--;
        maxi = max( maxi, diff );
    }
    cout << max( 0, maxi - 1 );
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:9:10: error: 'i' was not declared in this scope
    9 |     for( i = 1; i <= q; i++ ) {
      |          ^
Main.cpp:10:16: error: 'x' was not declared in this scope
   10 |         cin >> x;
      |                ^