Submission #977048

#TimeUsernameProblemLanguageResultExecution timeMemory
9770480pt1mus23Bigger segments (IZhO19_segments)C++14
13 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(),v.end() #define ins insert #define pb push_back #define int long long #define endl '\n' /* m : 11059739 -> l ~23 p : 4567896467 */ const int mod = 1e9 +7, sze=2*1e5,inf=LLONG_MAX, prime = 2333; void gkd(){ int n; cin>>n; vector<int> ps(n+1); vector<int> arr(n+1); for(int i=1;i<=n;i++){ cin>>arr[i]; ps[i]+=ps[i-1]+arr[i]; } vector<int> dp(n+1),from(n+1); for(int i=1;i<=n;i++){ from[i]=max(from[i],from[i-1]); dp[i]=dp[from[i]]+1; int t= lower_bound(all(ps),ps[i]*2 - ps[from[i]]) -ps.begin(); // cout<<t<<" -> "<<i<<" "<<dp[i]<<" ! "<<ps[i]*2 <<" "<< ps[from[i]]<<endl; from[t]=i; } cout<<dp[n]<<endl; } signed main(){ cin.tie(0)->sync_with_stdio(0); int tt=1; // cin>>tt; while(tt--) gkd(); 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...