# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573130 | duypd4206 | Swap (BOI16_swap) | C++14 | 2 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back
typedef pair<int,int> ii;
using ll = long long ;
const int maxn = 1e5 + 1;
const int oo = 1e9 + 7;
const ll ooo = 2e18 + 7;
const int mod = 1e9 + 7;
int a[maxn];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifndef ONLINE_JUDGE
#define file ""
freopen(file"inp","r",stdin);
freopen(file"out","w",stdout);
#endif //ONLINE_JUDGE
int n;
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 2; i <= n; i+=2){
int k = i/2;
int mn = min({a[k], a[i], a[i+1]});
if(a[k] == mn) continue;
if(a[i] == mn)
{
swap(a[i], a[k]);
continue;
}
if(a[i] < a[k]) swap(a[i], a[k]), swap(a[k], a[i+1]);
else swap(a[k], a[i+1]);
}
for(int i = 1; i <= n; i++)
cout << a[i] << " ";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |