Submission #815974

#TimeUsernameProblemLanguageResultExecution timeMemory
815974null_aweStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
567 ms157652 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...