Submission #374076

#TimeUsernameProblemLanguageResultExecution timeMemory
374076mariowongBigger segments (IZhO19_segments)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; long long n,a[3005],pt; pair <long long,long long> dp[3005]; long long ps[3005],ans; int main(){ ios::sync_with_stdio(false); cin >> n; for (int i=1;i<=n;i++){ cin >> a[i]; ps[i]=ps[i-1]+a[i]; } pt=1; for (int i=1;i<=n;i++){ dp[i]=make_pair(ps[i],1); while (pt+1 < i && ps[i]-ps[pt+1] >= dp[pt].first){ pt++; } dp[i]=make_pair(ps[i]-ps[j],dp[j].second+1); } cout << dp[n].second << "\n"; return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:20:28: error: 'j' was not declared in this scope
   20 |   dp[i]=make_pair(ps[i]-ps[j],dp[j].second+1);
      |                            ^