# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
344544 | Nurlykhan | Bigger segments (IZhO19_segments) | C++17 | 1 ms | 364 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 get(int it) {
ll sum = 0;
for (int i = 0; i <= it; i++) {
sum += a[i];
}
int cnt = 0;
//cout << "(" << 0 << ", "<< it << ") " << sum << "\n";
it++;
while (it < n) {
ll cur_sum = 0;
// cout << "(" << it << ", ";
while (it < n && cur_sum < sum) {
cur_sum += a[it];
it++;
}
// cout << it - 1 << ") " << cur_sum << "\n";
if (cur_sum >= sum) {
cnt++;
}
sum = cur_sum;
}
return cnt + 1;
}
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
pref[i] = pref[i - 1] + a[i];
}
//8 2 8 7 2 8 2 8 5 2
int ans = 0;
ans = 0;
for (int i = 0; i < n; i++) {
ans = max(ans, get(i));
}
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... |