제출 #860591

#제출 시각아이디문제언어결과실행 시간메모리
860591Halym2007Bigger segments (IZhO19_segments)C++11
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; const int N = 5e5 + 5; ll o, a[N], seg[N], sum; int main () { // freopen("input.txt", "r", stdin); int n; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } o++; seg[o] = a[1]; for (int i = 2; i <= n; ++i) { int r = i; sum = 0; while (r <= n and sum < seg[o]) { sum += a[r]; r++; } if (sum >= seg[o]) { o++; seg[o] = sum; while (sum - a[i] >= seg[i - 1] + a[i]) { seg[o - 1] += a[i]; seg[o] -= a[i]; } } else { seg[o] += sum; } i = r - 1; } cout << o << endl; }

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

segments.cpp:4:1: error: 'll' does not name a type
    4 | ll o, a[N], seg[N], sum;
      | ^~
segments.cpp: In function 'int main()':
segments.cpp:10:10: error: 'a' was not declared in this scope
   10 |   cin >> a[i];
      |          ^
segments.cpp:12:2: error: 'o' was not declared in this scope
   12 |  o++;
      |  ^
segments.cpp:13:2: error: 'seg' was not declared in this scope
   13 |  seg[o] = a[1];
      |  ^~~
segments.cpp:13:11: error: 'a' was not declared in this scope
   13 |  seg[o] = a[1];
      |           ^
segments.cpp:16:3: error: 'sum' was not declared in this scope
   16 |   sum = 0;
      |   ^~~