# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291152 | 2020-09-04T19:21:20 Z | thiago4532 | Bigger segments (IZhO19_segments) | C++17 | 3 ms | 640 KB |
#include <bits/stdc++.h> #define int int64_t using namespace std; const int maxn = 5e5 + 10; typedef long long ll; int dp[maxn], bb[maxn]; int n, v[maxn], pref[maxn]; int32_t main() { ios::sync_with_stdio(false), cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> v[i]; pref[i] = pref[i-1] + v[i]; } for (int i = 1; i <= n; i++) { bb[i] = max(bb[i], bb[i-1]); dp[i] = dp[ bb[i] ] + 1; int soma = pref[i] - pref[bb[i]]; int ini = i+1, fim = n, meio, best; while (ini <= fim) { meio = (ini + fim) >> 1; if (pref[meio] + pref[ bb[i] ] >= 2*pref[i]) { fim = meio-1; best = meio; }else ini = meio+1; } bb[best] = i; } cout << dp[n] << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Runtime error | 3 ms | 640 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Runtime error | 3 ms | 640 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Runtime error | 3 ms | 640 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Runtime error | 3 ms | 640 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 416 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Runtime error | 3 ms | 640 KB | Execution killed with signal 11 |
5 | Halted | 0 ms | 0 KB | - |