Submission #1118486

#TimeUsernameProblemLanguageResultExecution timeMemory
1118486HuyATBigger segments (IZhO19_segments)C++14
0 / 100
2 ms348 KiB
#include<bits/stdc++.h> #define newl '\n' const int N = 5e5 + 10; const int V = 1e7 + 10; const long long INF = 1e18; const long long M = 1e9 + 7; int a[N + 1],n; void readData(){ std::cin >> n; for(int i = 1;i <= n;++i){ std::cin >> a[i]; } } int solve(){ long long last = 0,cnt = 0,j = 1,s = 0; for(int i = 1;i <= n;++i){ s += a[i]; if(s >= last){ while(s - a[j] >= last + a[j]){ s -= a[j]; last += a[j]; ++j; } ++cnt; last = s; s = 0; j = i + 1; } } return cnt; } int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr);std::cout.tie(nullptr); readData(); std::cout << solve(); 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...