제출 #853931

#제출 시각아이디문제언어결과실행 시간메모리
853931Trisanu_DasBigger segments (IZhO19_segments)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second pair<int,long long> dp[500005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n]; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 1; i < n; i++) a[i] += a[i - 1]; dp[0][0] = 1; dp[0][1] = 0; for(int i = 1; i < n; i++){ dp[i] = max(dp[i], dp[i - 1]); int x = lower_bound(a, a + n, 2 * a[i] - dp[i].ss) - a; dp[x] = max(dp[x], {dp[i].ff + 1, a[i]}); } cout << dp[n - 1].ff << '\n'; }

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

segments.cpp: In function 'int main()':
segments.cpp:13:8: error: no match for 'operator[]' (operand types are 'std::pair<int, long long int>' and 'int')
   13 |   dp[0][0] = 1; dp[0][1] = 0;
      |        ^
segments.cpp:13:22: error: no match for 'operator[]' (operand types are 'std::pair<int, long long int>' and 'int')
   13 |   dp[0][0] = 1; dp[0][1] = 0;
      |                      ^