Submission #168285

#TimeUsernameProblemLanguageResultExecution timeMemory
168285NordwayBigger segments (IZhO19_segments)C++14
0 / 100
2 ms396 KiB
#include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define x first #define y second #define pb push_back #define mp make_pair #define all(v) v.begin(),v.end() #define sz(v) (int)v.size() #define up_b upper_bound #define low_b lower_bound #define nl '\n' using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef long double ld; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set; const int N=5e5+11; const int M=1e6+11; const int inf=1e9; const ll INF=1e18; const ll mod=1e9+7; const double EPS=1e-9; int a[N]; ll p[N]; int dp[N]; ll val[N]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; p[i]=p[i-1]+a[i]; } int j=0; dp[0]=0; val[0]=0; for(int i=1;i<=n;i++){ while(val[j]+p[j]<=p[i]&&j<i){ j++; } j--; dp[i]=dp[j]+1; val[i]=p[i]-p[j]; } cout<<dp[n]; }
#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...