# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
37665 | 2017-12-26T17:26:24 Z | szawinis | Lightning Conductor (POI11_pio) | C++14 | 399 ms | 5932 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5+1; int n, h[N], res[N]; void solve(int l, int r, int optL, int optR) { if(l > r) return; int mid = l+r >> 1, opt = optL; for(int i = optL; i <= min(optR, mid); i++) if(h[i] + sqrt(mid - i) > h[opt] + sqrt(mid - opt)) opt = i; res[mid] = max(h[opt] + (int) ceil(sqrt(mid - opt)) - h[mid], res[mid]); solve(l, mid-1, optL, opt); solve(mid+1, r, opt, optR); } int main() { scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &h[i]); solve(0, n-1, 0, n-1); reverse(h, h+n); reverse(res, res+n); solve(0, n-1, 0, n-1); reverse(h, h+n); reverse(res, res+n); for(int i = 0; i < n; i++) printf("%d\n", res[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 5932 KB | Output is correct |
2 | Correct | 39 ms | 5932 KB | Output is correct |
3 | Correct | 43 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 66 ms | 5932 KB | Output is correct |
2 | Correct | 66 ms | 5932 KB | Output is correct |
3 | Correct | 69 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 179 ms | 5932 KB | Output is correct |
2 | Correct | 156 ms | 5932 KB | Output is correct |
3 | Correct | 153 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 276 ms | 5932 KB | Output is correct |
2 | Correct | 249 ms | 5932 KB | Output is correct |
3 | Correct | 233 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 363 ms | 5932 KB | Output is correct |
2 | Correct | 363 ms | 5932 KB | Output is correct |
3 | Correct | 326 ms | 5932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 399 ms | 5932 KB | Output is correct |
2 | Correct | 363 ms | 5932 KB | Output is correct |
3 | Correct | 333 ms | 5932 KB | Output is correct |