# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095419 | Kerim | Bigger segments (IZhO19_segments) | C++17 | 1594 ms | 2548 KiB |
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"
#define ll long long
using namespace std;
const int N = 2e5+4;
ll a[N], b[N], par[N];
int main(){
// freopen("file.in", "r", stdin);
int n;
scanf("%d", &n);
for(int i = 1; i <= n; ++i){
int x;
scanf("%d", &x);
par[i] = par[i-1]+x;
}
a[1] = par[1];
b[1] = 1;
for(int i = 1; i <= n; ++i)
for(int j = i; j >= 1; --j)
if(par[i]-par[j-1] >= a[j-1] and b[j-1]+1 > b[i]){
b[i] = b[j-1] + 1;
a[i] = par[i]-par[j-1];
}
printf("%lld\n", b[n]);
return 0;
}
Compilation message (stderr)
# | 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... |