# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
158431 | 2019-10-17T03:10:38 Z | luciocf | Lightning Conductor (POI11_pio) | C++14 | 1000 ms | 45628 KB |
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") using namespace std; const int maxn = 5e5+5; const int maxl = 21; int n; int a[maxn]; int tab[maxn][maxl]; int lg[maxn]; void build(void) { for (int i = 1; i <= n; i++) { tab[i][0] = a[i]; if (i > 1) lg[i] = lg[i/2]+1; } for (int j = 1; j < maxl; j++) for (int i = 1; i + (1<<j) <= n+1; i++) tab[i][j] = max(tab[i][j-1], tab[i+(1<<(j-1))][j-1]); } int mx(int l, int r) { int j = lg[r-l+1]; return max(tab[l][j], tab[r-(1<<j)+1][j]); } int main(void) { scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); build(); for (int i = 1; i <= n; i++) { int k = 0; for (int d = 1; (d-1)*(d-1) <= max(i, n-i); d++) { int l = max(1, i - d*d); int r = min(i-1, i - d*d + 2*d - 2); if (l <= r) k = max(k, mx(l, r) + d); l = max(i+1, d*d - 2*d + i + 2); r = min(n, i + d*d); if (l <= r) k = max(k, mx(l, r) + d); } printf("%d\n", max(0, k-a[i])); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 3380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 199 ms | 5356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 285 ms | 6556 KB | Output is correct |
2 | Correct | 285 ms | 6404 KB | Output is correct |
3 | Correct | 286 ms | 6704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 533 ms | 9744 KB | Output is correct |
2 | Correct | 525 ms | 9496 KB | Output is correct |
3 | Correct | 532 ms | 10176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1056 ms | 21424 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 32620 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1072 ms | 45628 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1063 ms | 45592 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |