# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
210186 | 2020-03-16T19:29:06 Z | super_j6 | Xoractive (IZhO19_xoractive) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define endl '\n' #define pi pair<int, int> const int maxn = 100000; int n; long long a[maxn], sum[maxn]; int solve(long long x){ long long ret = 0, s = 0; x = sum[x]; for(int i = 0; i < n; i++){ s += a[i]; if(s >= x){ x = s; s = 0; ret++; } } return ret; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; sum[i] = a[i] + (i ? sum[i - 1] : 0); } int ret = 0; for(int i = 0; i < n; i++) ret = max(ret, solve(i)); cout << ret << endl; return 0; }