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 ll long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
signed main(){
int n,k;
cin>>n>>k;
vector <int> a(n);
map <int,int> mp;
for(int i=0;i<n;i++){
cin>>a[i];
mp[a[i]]++;
}
int val=-1,ins=-1;
for(auto x: mp){
if(x.ss==2){
if(mp[x.ff+1]==0){
val=x.ff+1;
ins=x.ff;
break;
}
}
}
for(int i=0;i<n;i++){
if(a[i]==ins && val!=-1){
cout<<val<<" "<<a[i]<<" ";
val=-1;
}
else{
cout<<a[i]<<" ";
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |