# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
122986 | 2019-06-29T22:21:48 Z | thebes | Swap (BOI16_swap) | C++14 | 2 ms | 504 KB |
#include <bits/stdc++.h> using namespace std; const int MN = 2e5+5; vector<int> tmp; int arr[MN], n, i, j, p[MN]; int main(){ for(scanf("%d",&n),i=1;i<=n;i++) scanf("%d",&arr[i]); for(i=1;i<=n;i++){ p[i]=1<<30; if(2*i<=n) p[i]=min(p[i],arr[2*i]); if(2*i+1<=n) p[i]=min(p[i],arr[2*i+1]); } for(i=1;i<=n;i++){ if(2*i>n) continue; else if(2*i+1>n){ if(arr[2*i]<arr[i]) swap(arr[i],arr[2*i]); } else{ if(arr[2*i+1]<arr[i]&&arr[2*i+1]<arr[2*i]){ swap(arr[i],arr[2*i+1]); int a = min(arr[2*i],arr[2*i+1]), b = max(arr[2*i],arr[2*i+1]); if(a<p[2*i]) arr[2*i]=a,arr[2*i+1]=b; else if(a<p[2*i+1]) arr[2*i+1]=a,arr[2*i]=b; else arr[2*i]=a,arr[2*i+1]=b; } else{ if(arr[2*i]<arr[i]) swap(arr[2*i],arr[i]); if(arr[2*i+1]<arr[i]) swap(arr[2*i+1],arr[i]); } } } for(i=1;i<=n;i++) printf("%d ",arr[i]); printf("\n"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 504 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Incorrect | 2 ms | 376 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |