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 int long long
int n;
signed main() {
// Input:
ios::sync_with_stdio(false); cin.tie(nullptr);
cin>>n;
vector<pair<int,int>> a(n);
vector<pair<int,int>> ainx(n,{0,-1});
for (int i = 0; i < n; i++) {
cin >> ainx[i].first;
a[i]={ainx[i].first,i};
}
sort(a.begin(),a.end());
for (int i = 1; i < n; i++)
{
if(a[i].first==a[i-1].first){
ainx[a[i-1].second].second=a[i].second;
}
}
int s=0;
while(s<n)
{
if(ainx[s].second!=-1){
for (int i = s; i < ainx[s].second; i++)
{
cout << ainx[s].first << "\n";
}
s=ainx[s].second;
}else {
cout << ainx[s].first << "\n";
s++;
}
}
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... |