This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#include "interactive.h"
#define pb push_back
#define F first
#define S second
#define ll long long
#define ld long double
#define sqr(x) (x) * (x)
//#define all(a) a.begin(), a.end()
using namespace std;
const int maxn = 500030;
int a[maxn];
int main()
{
#ifdef LOCAL
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif // LOCAL
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
int n;
cin >> n;
for(int i = 0; i < n; ++i)
cin >> a[i];
int ans = 0;
for(int k = 1; k <= n; ++k)
{
ll pr = 0;
for(int i = 0; i < k; ++i)
pr += a[i];
ll kek = 0;
int ot = 1;
for(int i = k; i < n; ++i)
{
kek += a[i];
// cerr << kek << ' ' << pr << endl;
if (kek >= pr)
{
pr = kek;
++ot;
kek = 0;
}
}
ans = max(ans, ot);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |