제출 #863390

#제출 시각아이디문제언어결과실행 시간메모리
863390ArthasGlobal Warming (CEOI18_glo)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(),x.end(); int N = 3e5 + 10, INF = 2e9 + 10; int n, x, a[N], l[N], ans; vector <int> v(N, INF); int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> x; for (int i = 0; i < n; ++ i){ cin >> a[i]; } v[0] = -INF; for (int i = 0; i < n; ++ i){ int p = lower_bound (all(v), a[i]) - v.begin(); v[p] = a[i]; l[i] = p; ans = max (ans, p); } for (int i = 0; i < n; ++ i){ v[i] = INF; } v[0] = -INF; for (int i = n - 1; i >= 0; -- i){ int p = lower_bound (all(v), -a[i] + x) - v.begin(); ans = max (ans, l[i] + p - 1); p = lower_bound (all(v), -a[i]) - v.begin(); v[p] = -a[i]; } cout << ans; return 0; }

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

glo.cpp:8:14: error: array bound is not an integer constant before ']' token
    8 | int n, x, a[N], l[N], ans;
      |              ^
glo.cpp:8:20: error: array bound is not an integer constant before ']' token
    8 | int n, x, a[N], l[N], ans;
      |                    ^
glo.cpp: In function 'int main()':
glo.cpp:16:12: error: 'a' was not declared in this scope
   16 |     cin >> a[i];
      |            ^
glo.cpp:4:33: error: expected ')' before ';' token
    4 | #define all(x) x.begin(),x.end();
      |                                 ^
glo.cpp:20:26: note: in expansion of macro 'all'
   20 |     int p = lower_bound (all(v), a[i]) - v.begin();
      |                          ^~~
glo.cpp:20:25: note: to match this '('
   20 |     int p = lower_bound (all(v), a[i]) - v.begin();
      |                         ^
glo.cpp:20:32: error: expected primary-expression before ',' token
   20 |     int p = lower_bound (all(v), a[i]) - v.begin();
      |                                ^
glo.cpp:20:34: error: 'a' was not declared in this scope
   20 |     int p = lower_bound (all(v), a[i]) - v.begin();
      |                                  ^
glo.cpp:22:5: error: 'l' was not declared in this scope
   22 |     l[i] = p;
      |     ^
glo.cpp:4:33: error: expected ')' before ';' token
    4 | #define all(x) x.begin(),x.end();
      |                                 ^
glo.cpp:30:26: note: in expansion of macro 'all'
   30 |     int p = lower_bound (all(v), -a[i] + x) - v.begin();
      |                          ^~~
glo.cpp:30:25: note: to match this '('
   30 |     int p = lower_bound (all(v), -a[i] + x) - v.begin();
      |                         ^
glo.cpp:30:32: error: expected primary-expression before ',' token
   30 |     int p = lower_bound (all(v), -a[i] + x) - v.begin();
      |                                ^
glo.cpp:30:35: error: 'a' was not declared in this scope
   30 |     int p = lower_bound (all(v), -a[i] + x) - v.begin();
      |                                   ^
glo.cpp:31:21: error: 'l' was not declared in this scope
   31 |     ans = max (ans, l[i] + p - 1);
      |                     ^
glo.cpp:4:33: error: expected ')' before ';' token
    4 | #define all(x) x.begin(),x.end();
      |                                 ^
glo.cpp:32:22: note: in expansion of macro 'all'
   32 |     p = lower_bound (all(v), -a[i]) - v.begin();
      |                      ^~~
glo.cpp:32:21: note: to match this '('
   32 |     p = lower_bound (all(v), -a[i]) - v.begin();
      |                     ^
glo.cpp:32:28: error: expected primary-expression before ',' token
   32 |     p = lower_bound (all(v), -a[i]) - v.begin();
      |                            ^