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;
int n, k, m;
vector<int> a;
void solve() {
cin >> n;
a.clear();
a.resize(n);
vector<pair<int, int>> temp;
for (int i=0; i<n; i++) {
cin >> a[i];
temp.push_back({a[i], i});
}
sort(temp.begin(), temp.end());
vector<int> ancien=a;
a[temp[0].second]=0;
int vv=0;
for (int i=1; i<n; i++) {
if (temp[i].first!=temp[i-1].first) vv++;
a[temp[i].second]=vv;
}
vector<int> apparition(vv+1, -1);
for (int i=0; i<n; i++) {
apparition[a[i]]=i;
}
for (int i=0; i<n; i++) {
int ct=ancien[i];
int temp=apparition[a[i]];
for (; i<temp; i++) {
cout << ct << endl;
}
cout << ct << endl;
}
return;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
solve();
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... |