#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x),end(x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
ll const inf = 1e9;
ll const mod = 998244853;
ld const eps = 1e-9;
int main()
{
int n, k;
cin >> n >> k;
int a[n];
int b[n];
int MIN = 40;
int nxt[n];
fr(i, 0, n){
cin >> a[i];
b[i] = a[i];
MIN = min(a[i], MIN);
nxt[i] = i + 1;
}
nxt[n - 1] = n - 1;
vector<pii> v;
int sz = n;
fr(mi, MIN, 30){
int p = 0;
fr(i, 0, sz - 1){
if(a[p] == mi){
if(a[nxt[p]] == mi){
a[p] = mi + 1;
nxt[p] = nxt[nxt[p]];
}
else{
v.pb({i, mi});
a[p] = mi + 1;
}
}
p = nxt[p];
}
}
sort(v.begin(), v.end());
int j = 0;
fr(i, 0, n){
while(j < v.size() && v[j].st == i){
cout << v[j].nd <<' ';
j ++;
}
cout << b[i] <<' ';
}
cout <<endl;
return 0;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:54:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j < v.size() && v[j].st == i){
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
477 ms |
16376 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
474 ms |
16248 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
478 ms |
16248 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
475 ms |
16240 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
493 ms |
16376 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
482 ms |
16248 KB |
Unexpected end of file - int32 expected |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
472 ms |
16120 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
480 ms |
16248 KB |
not a zalsequence |
3 |
Incorrect |
487 ms |
16248 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
476 ms |
16296 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
474 ms |
16376 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
478 ms |
16204 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
480 ms |
16248 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
477 ms |
16248 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
408 ms |
14692 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
197 ms |
6656 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
270 ms |
10012 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |