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
#define sz(x) (int)(x.size())
int n, k, m;
vector<int> a;
void solve() {
cin >> n;
a.clear();
a.resize(n);
map<int, int> vaut;
for (auto &u: a) cin >> u;
vector<int> temp=a;
vector<int> ancien=a;
sort(temp.begin(), temp.end());
vaut[temp[0]]=0;
int vv=0;
for (int i=1; i<n; i++) {
if (temp[i]!=temp[i-1]) vv++;
vaut[temp[i]]=vv;
}
vector<int> apparition(n+1, -1);
for (int i=0; i<n; i++) {
a[i]=vaut[a[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... |