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>
#define int int64_t
using namespace std;
void setIO() {
cin.tie(0)->sync_with_stdio(0);
}
void solve() {
//cout << "zco";
int n;
cin >> n;
vector<int> stones(n);
map<int, vector<int>> pos;
for(int i = 0; i < n; i++) {
cin >> stones[i];
pos[stones[i]].push_back(i);
}
// cout << pos[2].back() << '\n';
vector<int> ans(n);
int idx = 0, i = 0;
while(i < n && idx < n) {
for(i = idx; i <= pos[stones[idx]].back(); i++) ans[i] = stones[idx];
idx = i;
}
for(auto &x : ans) cout << x << '\n';
}
int32_t main() {
setIO();
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... |