#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] << " ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
181 ms |
29800 KB |
Output is correct |
2 |
Correct |
175 ms |
29816 KB |
Output is correct |
3 |
Correct |
157 ms |
29816 KB |
Output is correct |
4 |
Correct |
171 ms |
29916 KB |
Output is correct |
5 |
Correct |
220 ms |
29944 KB |
Output is correct |
6 |
Correct |
184 ms |
29892 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
171 ms |
29816 KB |
not a zalsequence |
2 |
Incorrect |
188 ms |
30456 KB |
not a zalsequence |
3 |
Incorrect |
191 ms |
30968 KB |
not a zalsequence |
4 |
Incorrect |
179 ms |
29944 KB |
not a zalsequence |
5 |
Incorrect |
204 ms |
29848 KB |
not a zalsequence |
6 |
Incorrect |
228 ms |
29916 KB |
not a zalsequence |
7 |
Incorrect |
184 ms |
29816 KB |
not a zalsequence |
8 |
Incorrect |
208 ms |
29788 KB |
not a zalsequence |
9 |
Incorrect |
991 ms |
49348 KB |
not a zalsequence |
10 |
Execution timed out |
1077 ms |
43012 KB |
Time limit exceeded |
11 |
Execution timed out |
1093 ms |
47840 KB |
Time limit exceeded |
12 |
Execution timed out |
1085 ms |
30400 KB |
Time limit exceeded |
13 |
Execution timed out |
1076 ms |
30216 KB |
Time limit exceeded |
14 |
Execution timed out |
1082 ms |
30620 KB |
Time limit exceeded |