# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
123606 | 2019-07-01T18:07:11 Z | MohamedAhmed04 | Lightning Conductor (POI11_pio) | C++14 | 161 ms | 14072 KB |
#include <bits/stdc++.h> using namespace std ; const int MAX = 5e5 + 5 ; int arr[MAX] , pref[MAX] , suff[MAX]; int n ; int main() { scanf("%d" , &n) ; for(int i = 0 ; i < n ; ++i) scanf("%d" , &arr[i]) ; int MAX = -1 ; for(int i = 0 ; i < n ; ++i) { if(arr[i] <= MAX) continue ; MAX = arr[i] ; for(int j = 1 ; i + (j-1) * (j-1) + 1 < n ; ++j) { pref[i + (j-1) * (j-1) + 1] = max(pref[i + (j-1) * (j-1) + 1] , arr[i] + j) ; } } MAX = -1 ; for(int i = n-1 ; i >= 0 ; --i) { if(arr[i] <= MAX) continue ; MAX = arr[i] ; for(int j = 1 ; i - (j-1) * (j-1) - 1 >= 0 ; ++j) { suff[i - (j-1) * (j-1) - 1] = max(suff[i - (j-1) * (j-1) - 1] , arr[i] + j) ; } } for(int i = 1 ; i < n ; ++i) pref[i] = max(pref[i] , pref[i-1]) ; for(int i = n-2 ; i >= 0 ; --i) suff[i] = max(suff[i] , suff[i+1]) ; for(int i = 0 ; i < n ; ++i) printf("%d\n" , max(0 , max(pref[i] , suff[i]) - arr[i])) ; return 0 ; }
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 | 11 ms | 1016 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 1404 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1392 KB | Output is correct |
2 | Correct | 14 ms | 1400 KB | Output is correct |
3 | Correct | 19 ms | 1656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 29 ms | 1912 KB | Output is correct |
2 | Correct | 26 ms | 1832 KB | Output is correct |
3 | Correct | 28 ms | 2424 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 64 ms | 4060 KB | Output is correct |
2 | Correct | 56 ms | 3960 KB | Output is correct |
3 | Correct | 61 ms | 4600 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 111 ms | 7928 KB | Output is correct |
2 | Correct | 89 ms | 6012 KB | Output is correct |
3 | Correct | 96 ms | 7984 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 161 ms | 11128 KB | Output is correct |
2 | Correct | 125 ms | 8184 KB | Output is correct |
3 | Correct | 142 ms | 11256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 143 ms | 8788 KB | Output is correct |
2 | Correct | 132 ms | 13176 KB | Output is correct |
3 | Correct | 139 ms | 14072 KB | Output is correct |