#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;
bool f(pii A, pii B){
if(A.st < B.st) return true;
else if(A.st > B.st) return false;
else A.nd > B.nd;
}
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;
vector<pii> v;
int sz = n;
fr(mi, MIN, 30){
int p = 0;
int CNT = 0;
fr(i, 0, sz){
if(nxt[p] == n){
if(a[p] == mi){
v.pb({p, mi});
a[p] ++;
}
}
else if(a[p] == mi){
if(a[nxt[p]] == mi){
a[p] = mi + 1;
nxt[p] = nxt[nxt[p]];
CNT ++;
}
else{
v.pb({p, mi});
a[p] = mi + 1;
}
}
p = nxt[p];
}
sz -= CNT;
p = 0;
}
sort(v.begin(), v.end(), f);
int j = 0;
k -= v.size();
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 'bool f(pii, pii)':
zalmoxis.cpp:21:20: warning: statement has no effect [-Wunused-value]
else A.nd > B.nd;
^
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:73:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j < v.size() && v[j].st == i){
~~^~~~~~~~~~
zalmoxis.cpp: In function 'bool f(pii, pii)':
zalmoxis.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
399 ms |
16124 KB |
Output is correct |
2 |
Correct |
400 ms |
16248 KB |
Output is correct |
3 |
Correct |
402 ms |
16248 KB |
Output is correct |
4 |
Correct |
413 ms |
16164 KB |
Output is correct |
5 |
Correct |
401 ms |
16204 KB |
Output is correct |
6 |
Correct |
409 ms |
16164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
401 ms |
16212 KB |
Unexpected end of file - int32 expected |
2 |
Correct |
403 ms |
16248 KB |
Output is correct |
3 |
Incorrect |
402 ms |
16144 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
406 ms |
16220 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
411 ms |
16232 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
401 ms |
16120 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
411 ms |
16260 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
416 ms |
16248 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
366 ms |
14436 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
160 ms |
6636 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
242 ms |
10016 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
372 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
376 KB |
Unexpected end of file - int32 expected |