#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
const ll mod = 1e9 + 7;
int n, k, cnt[31], cntmin[31];///min asta minimul necesar de adaugat, care dupa il manipulam cu shiretlikuri
int32_t main(){
ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
cin>>n>>k;
for(int i=1; i<=n; i++){
int x;
cin>>x;
cnt[x]++;
}
//for(int i=0; i<=30; i++) cnta[i]=cnt[i];
int pr=0;
for(int i=0; i<=29; i++){
if((cnt[i]+pr)%2) cntmin[i]++;
pr=(cnt[i]+pr+cntmin[i])/2;
//if(i>=25) cout<<i<<" "<<cnt[i]<<" "<<pr<<endl;
}
//for(int i=25; i<=30; i++) cout<<i<<" "<<cntmin[i]<<endl;
int cur=0, ix=30;
for(int i=0; i<=30; i++) cur+=cntmin[i];
//cout<<cur<<endl;
while(cur<k){
int xd=min(k-cur, cntmin[ix]);
if(cntmin[ix]){
cntmin[ix-1]+=2*xd;
cur+=xd;
cntmin[ix]-=xd;
//cout<<"xd";
}
//cout<<ix<<" "<<xd<<" "<<cur<<endl;
ix--;
}
for(int i=30; i>=0; i--){
for(int j=1; j<=cnt[i]+cntmin[i]; j++) cout<<i<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
4472 KB |
doesn't contain S as a subsequence |
2 |
Incorrect |
143 ms |
4472 KB |
doesn't contain S as a subsequence |
3 |
Incorrect |
145 ms |
4472 KB |
doesn't contain S as a subsequence |
4 |
Incorrect |
152 ms |
4472 KB |
doesn't contain S as a subsequence |
5 |
Incorrect |
150 ms |
4472 KB |
doesn't contain S as a subsequence |
6 |
Incorrect |
144 ms |
4392 KB |
doesn't contain S as a subsequence |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
4504 KB |
doesn't contain S as a subsequence |
2 |
Incorrect |
144 ms |
4552 KB |
doesn't contain S as a subsequence |
3 |
Incorrect |
145 ms |
4472 KB |
doesn't contain S as a subsequence |
4 |
Incorrect |
144 ms |
4472 KB |
doesn't contain S as a subsequence |
5 |
Incorrect |
147 ms |
4472 KB |
doesn't contain S as a subsequence |
6 |
Incorrect |
143 ms |
4472 KB |
doesn't contain S as a subsequence |
7 |
Incorrect |
145 ms |
4596 KB |
doesn't contain S as a subsequence |
8 |
Incorrect |
144 ms |
4600 KB |
doesn't contain S as a subsequence |
9 |
Incorrect |
130 ms |
4344 KB |
doesn't contain S as a subsequence |
10 |
Incorrect |
94 ms |
3704 KB |
doesn't contain S as a subsequence |
11 |
Incorrect |
112 ms |
3832 KB |
doesn't contain S as a subsequence |
12 |
Incorrect |
76 ms |
3448 KB |
doesn't contain S as a subsequence |
13 |
Incorrect |
75 ms |
3324 KB |
doesn't contain S as a subsequence |
14 |
Correct |
73 ms |
3320 KB |
Output is correct |