제출 #422634

#제출 시각아이디문제언어결과실행 시간메모리
422634snasibov05Global Warming (CEOI18_glo)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; #define oo 1000000000 int main() { int n, x; cin >> n >> x; vector<int> v(n); for (int i = 0; i < n; ++i) { cin >> v[i]; } int sz = 1; vector<int> dp(n); vector<int> c(n+1, oo); c[0] = 0; c[1] = v[0]; dp[0] = 1; for (int i = 1; i < n; ++i) { if (v[i] < c[1]) c[1] = v[i], dp[i] = 1; else if (v[i] > c[sz]) c[sz+1] = v[i], dp[i] = ++sz; else { int k = lower_bound(c.begin(), c.end(), v[i]) - c.begin(); c[k] = v[i]; dp[i] = k; } } int ans = dp[n-1]; c.assign(n+1, 0); c[n] = v[n-1] + x; sz = n; for (int i = n-2; i >= 0; --i){ if (v[i] > c[n]) ans = max(ans, dp[i]); else if (v[i] < c[sz]) ans = max(ans, dp[i] + n - sz + 1); else{ int k = upper_bound(c.begin(), c.end(), v[i]) - c.begin(); k = n - k + 1; ans = max(ans, dp[i] + k); } if (v[i] + x > c[n]) c[n] = v[i] + x; else if (v[i] + x < c[sz]) c[--sz] = v[i] + x; else{ int k = upper_bound(c.begin(), c.end(), v[i] + x) - c.begin(); k = n - k + 1; c[k-1] = v[i] + x; } } cout << ans << "\n"; return 0; }

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

glo.cpp: In function 'int main()':
glo.cpp:41:21: error: 'upper_bound' was not declared in this scope
   41 |             int k = upper_bound(c.begin(), c.end(), v[i]) - c.begin();
      |                     ^~~~~~~~~~~
glo.cpp:49:21: error: 'upper_bound' was not declared in this scope
   49 |             int k = upper_bound(c.begin(), c.end(), v[i] + x) - c.begin();
      |                     ^~~~~~~~~~~