Submission #372304

#TimeUsernameProblemLanguageResultExecution timeMemory
372304mariowongBigger segments (IZhO19_segments)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; int n,a[500005],dp[500005],ps[500005]; queue <pair<int,int> > q; pair<int,int> now; 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]; } for (int i=1;i<=n;i++){ while (!q.empty() && q.front().first <= ps[i]-ps[q.front().second]){ now=q.front(); q.pop(); } dp[i]=dp[now.second]+1; q.push(make_pair(ps[i]-ps[now.second],i)); } cout << dp[n] << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...