# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
118122 | 2019-06-18T08:23:59 Z | popovicirobert | Lightning Conductor (POI11_pio) | C++14 | 1000 ms | 8400 KB |
#include <bits/stdc++.h> #define lsb(x) (x & (-x)) #define ll long long #define ull unsigned long long // 217 // 44 using namespace std; const int MAXN = (int) 5e5 + 5; int pref[MAXN + 1], suff[MAXN + 1]; int h[MAXN + 1], sq[1000]; int main() { //ifstream cin("B.in"); //ofstream cout("B.out"); int i, n; //ios::sync_with_stdio(false); //cin.tie(0), cout.tie(0); scanf("%d" ,&n); for(i = 1; i <= n; i++) { scanf("%d" ,&h[i]); } for(i = 1; i < 1000; i++) { sq[i] = i * i; } for(int j = 1; j <= n; j++) { int pos; pref[j] = max(pref[j], h[j]); for(i = 1; j + sq[i - 1] < n; i++) { pos = j + sq[i - 1] + 1; pref[pos] = max(pref[pos], h[j] + i); } suff[j] = max(suff[j], h[j]); for(i = 1; j - sq[i - 1] - 1 >= 1; i++) { pos = j - sq[i - 1] - 1; suff[pos] = max(suff[pos], h[j] + i); } } for(i = 1; i <= n; i++) { pref[i] = max(pref[i], pref[i - 1]); } for(i = n; i >= 1; i--) { suff[i] = max(suff[i + 1], suff[i]); } for(i = 1; i <= n; i++) { printf("%d\n" ,max(pref[i], suff[i]) - h[i]); } //cin.close(); //cout.close(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 1280 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 34 ms | 1660 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 1640 KB | Output is correct |
2 | Correct | 43 ms | 1408 KB | Output is correct |
3 | Correct | 48 ms | 1912 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 2204 KB | Output is correct |
2 | Correct | 85 ms | 2144 KB | Output is correct |
3 | Correct | 88 ms | 2700 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 321 ms | 4332 KB | Output is correct |
2 | Correct | 316 ms | 4148 KB | Output is correct |
3 | Correct | 314 ms | 4872 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 726 ms | 8212 KB | Output is correct |
2 | Correct | 671 ms | 6020 KB | Output is correct |
3 | Correct | 695 ms | 8400 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 6064 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1064 ms | 6104 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |