#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define MAX ((ll)(1e12+100))
#define MX ((ll)(1e6+100))
#define ARRS ((ll)(2e6+100))
#define HS ((ll)(233))
#define MOD ((ll)(1e9+7))
#define EP ((double)(1e-9))
#define LG 21
#define mul(a,b) a=((a)*(b))%MOD
using namespace std;
ll a[ARRS];
ll f[ARRS];
ll n;
vector<ll> v;
ll go(ll x,ll i){
if(x==a[i]){v.pb(x);return i+1;}
//if(x>a[i]){
i=go(x-1,i);
if(x<=a[i]||i==n){
f[v.size()]=1;
v.pb(x-1);
}
else
i=go(x-1,i);
return i;
//}
}
vector<ll> pas;
ll splt(ll x,ll k){
//cout<<x<<" "<<k<<endl;
if(x==0)return k-1;
if(k==1){pas.pb(x);return 0;}
k--;
k=splt(x-1,k);
k++;
splt(x-1,k);
return k-1;
}
int main(){
#ifdef KHOKHO
freopen("in.in","r",stdin);
freopen("out.out","w",stdout);
#endif // KHOKHO
ios::sync_with_stdio(0);
ll k;
cin>>n>>k;
for(int i=0; i<n; i++){
cin>>a[i];
}
go(30,0);
ll ct=0;
for(int i=0; i<v.size(); i++){
//cout<<v[i]<<" "<<f[i]<<endl;
ct+=f[i];
}
//k-=v.size()-n;
// vector<ll> pas;
for(int i=0; i<v.size(); i++){
if(f[i])
k=splt(v[i],k-ct+1)+ct-1;
else pas.pb(v[i]);
}
for(auto x:pas){
cout<<x<<" ";
}
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:60:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
zalmoxis.cpp:66:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
211 ms |
28372 KB |
Output is correct |
2 |
Correct |
198 ms |
28400 KB |
Output is correct |
3 |
Correct |
207 ms |
28508 KB |
Output is correct |
4 |
Correct |
197 ms |
28704 KB |
Output is correct |
5 |
Correct |
198 ms |
28704 KB |
Output is correct |
6 |
Correct |
224 ms |
28704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
204 ms |
28704 KB |
Expected EOF |
2 |
Incorrect |
228 ms |
31728 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
203 ms |
33684 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
246 ms |
33684 KB |
Expected EOF |
5 |
Incorrect |
189 ms |
33684 KB |
Expected EOF |
6 |
Incorrect |
241 ms |
33684 KB |
Expected EOF |
7 |
Incorrect |
237 ms |
33684 KB |
Expected EOF |
8 |
Incorrect |
279 ms |
33684 KB |
Expected EOF |
9 |
Incorrect |
999 ms |
33900 KB |
Unexpected end of file - int32 expected |
10 |
Execution timed out |
1088 ms |
33900 KB |
Time limit exceeded |
11 |
Execution timed out |
1089 ms |
33900 KB |
Time limit exceeded |
12 |
Execution timed out |
1085 ms |
33900 KB |
Time limit exceeded |
13 |
Execution timed out |
1080 ms |
33900 KB |
Time limit exceeded |
14 |
Execution timed out |
1074 ms |
33900 KB |
Time limit exceeded |