Submission #342624

#TimeUsernameProblemLanguageResultExecution timeMemory
342624muhammad_hokimiyonBigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define dl double long using namespace std; const int N = 3e5 + 7; const long long mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int main() { ios_base::sync_with_stdio(0); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); int n; cin >> n; vector < ll > a( n + 1 , 0 ); for( int i = 1; i <= n; i++ ){ cin >> a[i]; } int ans = 1; ll ns = 0; ll ps = a[1]; int ls = 2; for( int i = 2; i <= n; i++ ){ if( ps <= ns ){ while( ns - 2 * a[ls] >= ps ){ ns -= a[ls]; ps += a[ls]; ls++; } ps = ns; ls = i; ans++; ns = a[i]; }else{ ns += a[i]; } } cout << ans + (ns >= ps); }
#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...