이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |