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 <iostream>
using namespace std;
int n, v[500001], seg[500001], k[500001];
unsigned long long sum[500001];
void read()
{
cin >> n;
for(int i = 1; i <= n; ++i)
{
cin >> v[i];
sum[i] = sum[i-1] + v[i];
}
}
int main()
{
read();
for(int i = 1; i <= n; ++i)
for(int j = 0; j < i; ++j)
if(sum[i] - sum[j] >= sum[j] - sum[seg[j]])
if(k[i] <= k[j] + 1)
{
k[i] = k[j] + 1;
seg[i] = j;
}
cout << k[n];
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... |