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 main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,a,c,b;
cin >> n;
map<int,int> haha;
vector<int> bruh(n);
vector<int> ans(n);
for(int i = 0; i < n; i++) {
cin >> a;
if(haha.find(a) == haha.end()) {
haha[a] = i;
}
bruh[i] = a;
}
c = bruh[n-1];
for(int i = n-1; i >= 0; i--) {
b = bruh[i];
if(haha[c] > haha[b]) {
c = b;
}
ans[i] = c;
}
for(int i = 0; i < n; i++) {
cout << ans[i] << " ";
}
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... |