제출 #103944

#제출 시각아이디문제언어결과실행 시간메모리
103944MrTEKZalmoxis (BOI18_zalmoxis)C++14
30 / 100
1093 ms49348 KiB
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<int,int> ii; const int N = 1e6 + 5; const int inf = 1e9; vector <ii> v; set <ii> S; set <ii> :: iterator it; vector <int> tut[N]; int n,k,a[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> k; for (int i = 1 ; i <= n ; i++) cin >> a[i]; for (int i = 1 ; i <= n ; i++) { int x = a[i],tut = i; while(v.empty() == false && v.back().first == x) { tut = v.back().second; v.pop_back(); x++; } v.push_back({x,tut}); } for (auto i : v) S.insert(i); while(k--) { it = S.begin(); tut[it->second].push_back(it->first); ii temp = {it->first + 1,it->second}; S.erase(it); S.insert(temp); } for (int i = 1 ; i <= n ; i++) { reverse(tut[i].begin(),tut[i].end()); for (auto j : tut[i]) cerr << j << " "; cout << a[i] << " "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...