# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
258507 |
2020-08-06T05:09:26 Z |
임성재(#5051) |
Swap (BOI16_swap) |
C++17 |
|
5 ms |
5248 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a)
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
int a[100010];
bool chk[100010];
int ans[100010];
vector<int> v[100010];
int main() {
fast;
cin >> n;
for(int i=1; i<=n; i++) {
cin >> a[i];
v[i].eb(a[i]);
}
for(int i=1; i<=n; i++) {
int x = inf;
for(auto j : v[i]) {
if(chk[j]) continue;
//cout << i << "!! " << j << endl;
x = min(x, j);
}
if(2 * i <= n) x = min(x, a[2*i]);
if(2*i+1 <= n) {
if(a[i*2+1] < x) {
x = a[i*2+1];
for(auto j : v[i]) {
v[i*2].eb(j);
v[i*2+1].eb(j);
}
v[i*2+1].eb(a[i*2]);
}
}
ans[i] = x;
chk[x] = true;
cout << x << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
5248 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |