이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |