Submission #937628

#TimeUsernameProblemLanguageResultExecution timeMemory
937628tw20000807Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
330 ms30988 KiB
#include<bits/stdc++.h> #define int long long #define pii pair<int, int> #define X first #define Y second using namespace std; signed main(){ int n; cin >> n; vector< int > v(n + 1); map<int, int> cnt; multiset< pii > s; for(int i = 1; i <= n; ++i){ cin >> v[i]; int id = i; while(cnt[v[i]] > 0){ auto it = prev(s.end()); --cnt[v[it->X]]; id = it->X; s.erase(it); } ++cnt[v[i]]; s.insert({id, v[id]}); } int now = n; while(!s.empty()){ auto it = prev(s.end()); for(; now >= it->X; --now){ v[now] = it->Y; } s.erase(it); } for(int i = 1; i <= n; ++i) cout << v[i] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...