# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
29524 | 2017-07-20T05:07:13 Z | 서규호(#1242) | Lightning Conductor (POI11_pio) | C++14 | 146 ms | 5036 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]; struct data{ deque<pii> q; void insert(int x){ while(!q.empty() && q.back().first <= a[x]) q.pop_back(); q.pb({a[x],x}); } int get(){ return q.front().first; } void erase(int x){ if(q.size() == 0) while(true); if(q.front().second == x) q.pop_front(); } bool empty(){ return (q.size() == 0); } }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].get()+i-a[num]); } if(!S2[i].empty()){ ans = max(ans,S2[i].get()+i-a[num]); } } } int main(){ 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(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(t); S1[j+1].insert(t); } S2[1].erase(i); for(int j=1; i+j*j<=N; j++){ int t = i+j*j; S2[j+1].erase(t); S2[j].insert(t); } calcans(i); printf("%d\n",ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 5036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 6 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 9 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 13 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 23 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 53 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 83 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 146 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 119 ms | 5036 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |