# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
81846 | 2018-10-27T08:16:47 Z | tmwilliamlin168 | Lightning Conductor (POI11_pio) | C++14 | 171 ms | 15408 KB |
#include <bits/stdc++.h> using namespace std; const int mxN=5e5; int n, h[mxN], a1[mxN], a2[mxN], sr[1000001], qu[mxN]; double ix(int i, int j) { double a=(j-i)/2.0/(h[j]-h[i])-(h[j]-h[i])/2.0; return a*a+j; } void solve(int a[mxN]) { for(int i=0, qh=0, qt=0; i<n; ++i) { if(!i||h[qu[qt-1]]<h[i]) { while(qt>qh&&h[i]>=h[qu[qt-1]]+sr[i-qu[qt-1]]||qt-qh>1&&ix(qu[qt-2], qu[qt-1])>ix(qu[qt-1], i)) --qt; qu[qt++]=i; } while(qt-qh>1&&i>ix(qu[qh], qu[qh+1])) ++qh; a[i]=h[qu[qh]]+sr[i-qu[qh]]; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); for(int i=1; i<=1000; ++i) for(int j=(i-1)*(i-1)+1; j<=i*i; ++j) sr[j]=i; cin >> n; for(int i=0; i<n; ++i) cin >> h[i]; solve(a1); for(int i=0; i<n-1-i; ++i) swap(h[i], h[n-1-i]); solve(a2); for(int i=0; i<n; ++i) cout << max(a1[i], a2[n-1-i])-h[n-1-i] << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4344 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 4348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 5032 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 5604 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 26 ms | 5604 KB | Output is correct |
2 | Correct | 28 ms | 5604 KB | Output is correct |
3 | Correct | 22 ms | 5696 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 6208 KB | Output is correct |
2 | Correct | 32 ms | 6208 KB | Output is correct |
3 | Correct | 28 ms | 6684 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 8348 KB | Output is correct |
2 | Correct | 53 ms | 8348 KB | Output is correct |
3 | Correct | 56 ms | 8852 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 92 ms | 12008 KB | Output is correct |
2 | Correct | 86 ms | 12008 KB | Output is correct |
3 | Correct | 82 ms | 12060 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 171 ms | 15276 KB | Output is correct |
2 | Correct | 121 ms | 15276 KB | Output is correct |
3 | Correct | 112 ms | 15276 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 138 ms | 15276 KB | Output is correct |
2 | Correct | 127 ms | 15276 KB | Output is correct |
3 | Correct | 115 ms | 15408 KB | Output is correct |