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<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
//typedef pair<ll,ll>Point;
//typedef pair<ll,ll>Line;
//#define x first
//#define y second
int main(){
ios::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int n;
cin>>n;
vector<int>arr(n);
multiset<int>s;
for(int&i:arr){
cin>>i;
s.insert(i);
}
for(int i=0;i<n;){
s.erase(s.find(arr[i]));
if(s.find(arr[i])!=s.end()){
int val=arr[i];
i++;
while(arr[i]!=val){
s.erase(s.find(arr[i]));
arr[i++]=val;
}
}else
i++;
}
for(int i:arr)
cout<<i<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |