# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
56139 | 2018-07-10T05:48:05 Z | 김세빈(#1581) | Swap (BOI16_swap) | C++11 | 8 ms | 6648 KB |
#include <bits/stdc++.h> using namespace std; priority_queue <int, vector <int>, greater <int> > Q[202020]; int A[202020], K[202020]; int n; int main() { int i, a, b, c; scanf("%d", &n); for(i=1;i<=n;i++){ scanf("%d", A+i); K[i] = i; Q[i].push(A[i]); } for(i=1;i<=n;i++){ a = Q[K[i]].top(); b = (i<<1) <= n? Q[i<<1].top() : 1e9; c = (i<<1|1) <= n? Q[i<<1|1].top() : 1e9; if(a < b && a < c){ printf("%d ", a); Q[K[i]].pop(); } else if(b < c){ printf("%d ", b); Q[K[i]].push(A[i<<1|1]); K[i<<1] = K[i<<1|1] = K[i]; } else{ printf("%d ", c); Q[K[i]].push(A[i<<1]); K[i<<1] = K[i<<1|1] = K[i]; } } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 6648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 6648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 6648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 6648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 6648 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |