| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 344525 | Nurlykhan | Bigger segments (IZhO19_segments) | C++17 | 949 ms | 620 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = (int)5e5 + 10;
const int mod = (int)1e9 + 7;
int n;
int a[N];
ll pref[N];
ll get_sum(int l, int r) {
return pref[r] - pref[l - 1];
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
pref[i] = pref[i - 1] + a[i];
}
int ans = 0;
for (int mask = 0; mask < (1 << (n - 1)); mask++) {
vector<int> pos;
pos.push_back(0);
for (int i = 0; i < n - 1; i++) {
if ((mask >> i) % 2) {
pos.push_back(i + 1);
}
}
pos.push_back(n);
bool bad = 0;
for (int i = 0; i + 2 < pos.size(); i++) {
if (get_sum(pos[i], pos[i + 1] - 1) > get_sum(pos[i + 1], pos[i + 2] - 1))
bad = 1;
}
if (!bad)
ans = max(ans, (int)pos.size() - 1);
}
printf("%d", ans);
return 0;
for (int i = 1; i <= n; i++) {
ll cur_sum = 0;
ll prev_sum = get_sum(1, i);
int cnt = 0, j = i + 1;
while (j <= n) {
cur_sum += a[j];
if (cur_sum >= prev_sum) {
prev_sum = cur_sum;
cur_sum = 0;
cnt++;
}
j++;
}
ans = max(ans, cnt + 1);
}
printf("%d", ans);
return 0;
}
컴파일 시 표준 에러 (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... | ||||
