제출 #556343

#제출 시각아이디문제언어결과실행 시간메모리
556343ngpin04Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms332 KiB
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define TASK "" #define ALL(x) (x).begin(), (x).end() using namespace std; template <typename T1, typename T2> bool mini(T1 &a, T2 b) { if (a > b) {a = b; return true;} return false; } template <typename T1, typename T2> bool maxi(T1 &a, T2 b) { if (a < b) {a = b; return true;} return false; } const int N = 5e5 + 5; const int oo = 1e9; const long long ooo = 1e18; const int mod = 1e9 + 7; // 998244353; const long double pi = acos(-1); int a[N]; int n; int main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef ONLINE_JUDGE // freopen(TASK".inp","r",stdin); // freopen(TASK".out","w",stdout); #endif cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; long long cur = 0; long long tot = 0; int ans = 0; for (int i = 1, j = 0; i <= n; i++) { tot += a[i]; if (tot >= cur) { ans++; while (j > 0 && (cur + a[j + 1]) <= (tot - a[j + 1])) { cur += a[j + 1]; tot -= a[j + 1]; j++; } cur = tot; tot = 0; j = i; } } cout << ans; 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...