# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
29520 | 2017-07-20T04:51:15 Z | 서규호(#1242) | Lightning Conductor (POI11_pio) | C++14 | 1000 ms | 27560 KB |
#include <bits/stdc++.h> #include <unistd.h> #define pii pair<int,int> #define pll pair<lld,lld> #define pb push_back #define next nextt #define left leftt #define right rightt #define lld long long #define Inf 1000000000 #define Mod 1000000007 #define Linf 1000000000000000000LL #define get gett using namespace std; int N,ans; int a[500002]; multiset<int> S1[800],S2[800]; void calcans(int num){ ans = 0; int e = sqrt(N-1); if(e*e != N-1) e++; for(int i=1; i<=e; i++){ if(!S1[i].empty()){ ans = max(ans,*S1[i].rbegin()+i-a[num]); } if(!S2[i].empty()){ ans = max(ans,*S2[i].rbegin()+i-a[num]); } } } int main(){ //freopen("input.txt","r",stdin); scanf("%d",&N); for(int i=1; i<=N; i++){ scanf("%d",&a[i]); } for(int i=2; i<=N; i++){ int t = sqrt(i-1); if(t*t != i-1) t++; S2[t].insert(a[i]); } calcans(1); printf("%d\n",ans); for(int i=2; i<=N; i++){ S1[1].insert(a[i-1]); for(int j=1; i-1-j*j>=1; j++){ int t = i-1-j*j; S1[j].erase(S1[j].find(a[t])); S1[j+1].insert(a[t]); } S2[1].erase(S2[1].find(a[i])); for(int j=1; i+j*j<=N; j++){ int t = i+j*j; S2[j+1].erase(S2[j+1].find(a[t])); S2[j].insert(a[t]); } calcans(i); printf("%d\n",ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 4064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 4064 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 5516 KB | Execution timed out |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 6440 KB | Execution timed out |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 7100 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 8684 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 14756 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 20564 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 27560 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1000 ms | 27560 KB | Execution timed out |
2 | Halted | 0 ms | 0 KB | - |