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 f first
#define s second
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<int> a(n), ans(n);
for (int i = 0;i < n;i++)
cin >> a[i];
map<int, int> b;
for (int i = 0;i < n;i++)
b[a[i]] = i;
int lst = -1;
for (int i = 0;i < n;i++) {
if (i == lst + 1)
lst = b[a[i]];
ans[i] = a[lst];
}
for (int i = 0;i < n;i++)
cout << ans[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... |