제출 #1118481

#제출 시각아이디문제언어결과실행 시간메모리
1118481HuyATBigger segments (IZhO19_segments)C++14
0 / 100
2 ms484 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 = a[1],cnt = 1,j = 2,s = 0; for(int i = 2;i <= n;++i){ s += a[i]; if(s >= last){ while(s - a[j] >= last){ 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...