# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
299746 | dantoh000 | Bigger segments (IZhO19_segments) | C++14 | 1538 ms | 1592 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 fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, int> li;
ii dp[500005];
int n;
ll p[500005];
int main(){
scanf("%d",&n);
for (int i = 1; i <= n; i++){
scanf("%lld",&p[i]);
p[i]+=p[i-1];
dp[i] = {0,0};
for (int j = i-1; j >= 0; j--){
if (p[i]-p[j] >= p[j]-p[dp[j].se]){
dp[i] = max(dp[i],{dp[j].fi+1, j});
break;
}
}
}
printf("%d",dp[n].fi);
}
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... |