# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
384336 | patrikpavic2 | Bigger segments (IZhO19_segments) | C++17 | 1592 ms | 3684 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 <cstdio>
#include <vector>
#include <algorithm>
#define X first
#define Y second
#define PB push_back
using namespace std;
typedef long long ll;
const int N = 5e5 + 500;
int A[N], n, dp[N];
ll P[N];
vector < pair < pair < ll, ll > , int > > pri;
int main(){
scanf("%d", &n);
for(int i = 0;i < n;i++){
scanf("%d", A + i);
P[i] = A[i] + (i ? P[i - 1] : 0LL);
}
pri.PB({{0, 0}, 0});
for(int i = 0;i < n;i++){
int naj = 0;
for(int j = 1;j < (int)pri.size();j++)
if(P[i] >= pri[j].X.X && pri[j].X.Y > pri[naj].X.Y)
naj = j;
dp[i] = pri[naj].Y + 1;
pri.PB({{2LL * P[i] - pri[naj].X.Y, P[i]}, dp[i]});
}
printf("%d\n", dp[n - 1]);
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... |