# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1066064 | manhlinh1501 | Bigger segments (IZhO19_segments) | C++17 | 1 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>
using namespace std;
using i64 = long long;
const int MAXN = 5e5 + 5;
int N;
int a[MAXN];
namespace subtask3 {
const int MAXN = 3e3 + 5;
int dp[MAXN][MAXN];
i64 prefix[MAXN];
void solution() {
for(int i = 1; i <= N; i++) prefix[i] = prefix[i - 1] + a[i];
int ans = 0;
for(int i = 1; i <= N; i++) {
int cnt = 0;
i64 cur = prefix[i];
for(int j = i; j <= N; j++) {
cnt++;
int z = j;
while(z <= N and prefix[z] - prefix[j] < cur)
z++;
cur = prefix[z] - prefix[j];
j = z - 1;
}
ans = max(ans, cnt);
}
cout << ans;
}
}
signed main() {
#define TASK "code"
if (fopen(TASK ".inp", "r")) {
freopen(TASK ".inp", "r", stdin);
freopen(TASK ".out", "w", stdout);
}
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
for(int i = 1; i <= N; i++) cin >> a[i];
subtask3::solution();
return (0 ^ 0);
}
/**
4
2 3 1 7
**/
/**
5
6 2 3 9 13
**/
/**
3
3 1 2
**/
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... |