제출 #891604

#제출 시각아이디문제언어결과실행 시간메모리
891604alex_2008Bigger segments (IZhO19_segments)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> typedef long long ll; using namespace std; const int N = 5e5 + 10; ll pref[N]; pair <ll, ll> dp[N]; int main() { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> pref[i]; pref[i] += pref[i - 1]; } dp[0] = { 0, 0 }; for (int i = 1; i <= n; i++) { dp[i] = { dp[i - 1].first, dp[i - 1].second + pref[i] - pref[i - 1] }; for (int j = 0; j < i; j++) { if (dp[j].second <= pref[i] - pref[j]) { if (dp[j].first + 1 > dp[i].first || (dp[j].second < dp[i].second && dp[j].first + 1 == dp[i].first)) { dp[i] = make_pair(dp[j].first + 1, pref[i] - pref[j]); } } } if (dp[i].second < dp[i - 1].second) throw "esim"; } cout << dp[i].first << "\n"; }

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

segments.cpp: In function 'int main()':
segments.cpp:26:13: error: 'i' was not declared in this scope
   26 |  cout << dp[i].first << "\n";
      |             ^