# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1095421 | Kerim | Bigger segments (IZhO19_segments) | C++17 | 1546 ms | 2516 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 = 2; i <= n; ++i){
int who, mx = 0;
for(int j = i; j >= 1; --j)
if(par[i] >= a[j-1]+par[j-1] and b[j-1]+1 > mx){
mx = b[j-1]+1;
who = j;
}
b[i] = b[who-1] + 1;
a[i] = par[i]-par[who-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... |