# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
290449 | 2020-09-03T20:11:37 Z | luciocf | Bigger segments (IZhO19_segments) | C++14 | 0 ms | 256 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 5e5+10; int n; int a[maxn]; int qtd(int p) { ll ant = 0; for (int i = 1; i <= p; i++) ant += 1ll*a[i]; int at = p; int ans = 1; while (at < n) { ++ans; ll aux = 0; int i; for (i = at+1; i <= n; i++) { aux += 1ll*a[i]; if (aux >= ant) break; } if (i > n) return -1; at = i; ant = aux; } return ans; } int main(void) { scanf("%d", &n); ll soma = 0; for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); soma += 1ll*a[i]; } int ini = 1, fim = 1, ans = 1; ll aux = 0; for (int i = n; i >= 1; i--) { aux += 1ll*a[i]; if (soma-aux <= aux) { fim = i; break; } } while (ini <= fim) { int mid = (ini+fim)>>1; if (qtd(mid) != -1) fim = mid-1, ans = qtd(mid); else ini = mid+1; } printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Incorrect | 0 ms | 256 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |