Submission #502925

#TimeUsernameProblemLanguageResultExecution timeMemory
502925Vladth11Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms320 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair <ll, ll> pii; typedef pair <long double, pii> muchie; const ll NMAX = 500001; const ll VMAX = 21; const ll INF = 1e9; const ll MOD = 1000000007; const ll BLOCK = 318; const ll base = 31; const ll nr_of_bits = 21; ll v[NMAX]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, i; cin >> n; ll init = 0, maxim = 0; for(i = 1; i <= n; i++) cin >> v[i]; for(int j = 1; j <= n; j++) { init += v[j]; ll cnt = 1, s = init, curent = 0; for(i = j + 1; i <= n; i++) { curent += v[i]; if(curent >= s) { cnt++; s = curent; curent = 0; } } maxim = max(maxim, cnt - (curent != 0)); } cout << maxim; 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...