제출 #937622

#제출 시각아이디문제언어결과실행 시간메모리
937622tw20000807Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
1 ms348 KiB
#include<bits/stdc++.h> #define int long long #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< pair<int, int> > s; for(int i = 1; i <= n; ++i){ cin >> v[i]; int id = i; while(cnt[v[i]]){ auto it = prev(s.end()); --cnt[v[it->Y]]; id = it->X; s.erase(it); } ++cnt[v[i]]; s.insert({id, v[i]}); } 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...