# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29561 | 2017-07-20T06:10:30 Z | 김동현(#1239) | Lightning Conductor (POI11_pio) | C++14 | 176 ms | 13752 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; int n; ll h[500010], la[500010], ra[500010]; struct CHT{ struct Cnv{ ll a, b; }; ld inv(Cnv p, ll y){ return sqrt(ld(y - p.b)) + p.a; } ll iinv(Cnv p, ll y){ ll s = 0, e = 710; while(s <= e){ ll m = (s + e) / 2; if(m * m >= y - p.b) e = m - 1; else s = m + 1; } return s + p.a; } vector<Cnv> v; int f; void ini(){ v.clear(); f = 0; } void upd(ll a, ll b){ Cnv cur = {a, b}; if(!v.empty() && v.back().a >= cur.a) return; while(v.size() > 1 && inv(v[int(v.size()) - 1], cur.b) <= inv(v[int(v.size()) - 2], cur.b)) v.pop_back(); v.push_back(cur); } ll get(ll y){ if(f == v.size()) return 0; while(int(v.size()) - f > 1 && inv(v[f], y) <= inv(v[f + 1], y)) f++; return iinv(v[f], y); } } C; void f(ll *a){ C.ini(); for(int i = 1; i <= n; i++){ a[i] = max(h[i], C.get(i)); C.upd(h[i], i); } } int main(){ scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%lld", h + i); f(la); reverse(h + 1, h + n + 1); f(ra); reverse(h + 1, h + n + 1); for(int i = 1; i <= n; i++) printf("%lld\n", max(la[i], ra[n + 1 - i]) - h[i]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 13752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 13752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 23 ms | 13752 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 36 ms | 13752 KB | Output is correct |
2 | Correct | 16 ms | 13752 KB | Output is correct |
3 | Incorrect | 16 ms | 13752 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 39 ms | 13752 KB | Output is correct |
2 | Correct | 36 ms | 13752 KB | Output is correct |
3 | Incorrect | 29 ms | 13752 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 116 ms | 13752 KB | Output is correct |
2 | Correct | 66 ms | 13752 KB | Output is correct |
3 | Incorrect | 59 ms | 13752 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 136 ms | 13752 KB | Output is correct |
2 | Correct | 123 ms | 13752 KB | Output is correct |
3 | Incorrect | 103 ms | 13752 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 173 ms | 13752 KB | Output is correct |
2 | Correct | 126 ms | 13752 KB | Output is correct |
3 | Incorrect | 176 ms | 13752 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 133 ms | 13752 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |