#include <bits/stdc++.h>
#define ll long long
#define st first
#define nd second
#define pii pair <ll, ll>
#define rep(i, n, m) for (ll i = (n); i <= (m); i ++)
#define rrep(i, n, m) for (ll i = (n); i >= (m); i --)
using namespace std;
const long long N = 2e6 + 10;
ll n, k, a[N], b[N], cnt;
vector <int> d[N];
void write(int v) {
if (v == 0 || k == 0) {
cout << v << ' ';
return;
}
if (k > 0) {
k --;
write(v - 1);
write(v - 1);
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
//freopen("test.inp", "r", stdin);
//freopen("test.out", "w", stdout);
cin >> n >> k;
vector <pii> b;
rep(i, 1, n) cin >> a[i], b.push_back({a[i], i});
int cnt = 0;
rep(val, 25, 29) {
vector <pii> v;
for (int id = 0; id < b.size(); id ++) {
int x = b[id].st;
if (val != x) v.push_back(b[id]);
else {
if (id + 1 < b.size() && b[id + 1].st == val)
v.push_back({val + 1, b[id + 1].nd}), id ++;
else {
d[b[id].nd].push_back(val);
v.push_back({val + 1, b[id].nd});
k --;
cnt ++;
if (k == 0) break;
}
}
if (k == 0) break;
}
if (k == 0) break;
b = v;
}
// k += cnt;
rep(i, 1, n) {
cout << a[i] << ' ';
for (int v: d[i]) {
// k --;
write(v);
// cout << v << ' ';
}
}
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:41:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for (int id = 0; id < b.size(); id ++) {
| ~~~^~~~~~~~~~
zalmoxis.cpp:45:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if (id + 1 < b.size() && b[id + 1].st == val)
| ~~~~~~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
249 ms |
104948 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
255 ms |
104968 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
252 ms |
104952 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
250 ms |
105028 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
244 ms |
104972 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
191 ms |
104700 KB |
not a zalsequence |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
241 ms |
104984 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
273 ms |
104888 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
251 ms |
104900 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
256 ms |
105044 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
231 ms |
104976 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
253 ms |
104996 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
262 ms |
104976 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
258 ms |
105028 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
202 ms |
96724 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
92 ms |
67912 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
130 ms |
76184 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
30 ms |
47188 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
24 ms |
47204 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
25 ms |
47264 KB |
Unexpected end of file - int32 expected |