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() {
int n; cin >> n;
map<int, stack<int>> m;
set<pair<int, int>> s;
for (int i = 0; i < n; ++i) {
int x; cin >> x;
if (m[x].size()) {
int a = m[x].top();
while (s.size()) {
pair<int, int> last = *--s.end();
if (last.first < a) break;
int y = last.second;
m[y].pop();
s.erase(last);
}
}
m[x].push(i);
s.insert({i, x});
// for (auto p : s) cout << p.first << ' ' << p.second << '\n';
// cout << '\n';
}
for (int i = 0; i < n; ++i) cout << s.lower_bound({i, 0})->second << '\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... |