// 01001100 01001111 01010100 01000001 \\
// \\
// ╦ ╔═╗╔╦╗╔═╗ \\
// ║ ║ ║ ║ ╠═╣ \\
// ╩═╝╚═╝ ╩ ╩ ╩ \\
// \\
// 01001100 01001111 01010100 01000001 \\
#include <bits/stdc++.h>
using namespace std;
#define N 1000002
#define nl '\n'
#define ff first
#define ss second
#define ll long long
#define ld long double
#define terminator main
#define pll pair<ll,ll>
#define append push_back
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int s[N];
int a[N];
int r[N];
vector<int> x[N];
void solve(){
int n, k, p;
cin >> n >> k;
a[n + 1] = 30;
priority_queue<pii, vector<pii>, greater<pii>> Q;
for(int i = 1; i <= n; i++){
cin >> s[i];
a[i] = s[i];
r[i] = i + 1;
Q.push({a[i], i});
}
while(Q.top().ff != 30){
p = Q.top().ss;
Q.pop();
if(a[p] == a[r[p]]){
Q.pop();
r[p] = r[r[p]];
}
else{
k--;
x[r[p] - 1].append(a[p]);
}
a[p]++;
Q.push({a[p], p});
}
for(int i = 1; i <= n; i++){
cout << s[i] << ' ';
for(auto & j : x[i])
cout << j << ' ';
}
}
int terminator(){
L0TA;
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |