Submission #1026231

#TimeUsernameProblemLanguageResultExecution timeMemory
1026231overwatch9Stone Arranging 2 (JOI23_ho_t1)C++17
60 / 100
2057 ms268500 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; map <int, vector <int>> mp; vector <int> ans(n+1); for (int i = 1; i <= n; i++) { cin >> ans[i]; if (!mp[ans[i]].empty()) { int lst = mp[ans[i]].back(); for (int j = lst+1; j < i; j++) { mp[ans[j]].pop_back(); mp[ans[i]].push_back(j); ans[j] = ans[i]; } } mp[ans[i]].push_back(i); } for (int i = 1; i <= n; i++) cout << ans[i] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...