#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=1e3+25;
const int off=(1<<18);
const int MOD = 1e9+7;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n,k;
cin >> n >> k;
vector<array<int,3>> a(n);
for(int i=0;i<n;i++){
cin >> a[i][0];
a[i][1]=a[i][2]=i;
}
vector<array<int,3>>v=a;
pair<int,int>kk,vv;
vv=kk={-1,-1};
for(int i=0;i<=30;i++){
vector<array<int,3>>t;
for(int j=0;j<v.size();j++){
if(j+1<v.size()&&v[j][0]==v[j+1][0]&&v[j][0]==i){
t.pb({v[j][0]+1,v[j][1],v[j+1][2]});
j++;
}
else if(v[j][0]==i&&kk.F==-1){
kk={v[j][0],v[j][2]};
// cout<<kk.F<<endl;
}
else if(v[j][0]==i&&vv.F==-1){
vv={v[j][0],v[j][2]};
// cout<<kk.F<<endl;
}
else{
t.pb(v[j]);
}
}
v=t;
}
for(int i=0;i<n;i++){
cout<<a[i][0]<<' ';
if(i==kk.S)cout<<kk.F<<' ';
}
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:29:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int j=0;j<v.size();j++){
| ~^~~~~~~~~
zalmoxis.cpp:30:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if(j+1<v.size()&&v[j][0]==v[j+1][0]&&v[j][0]==i){
| ~~~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
253 ms |
91040 KB |
Output is correct |
2 |
Correct |
270 ms |
91976 KB |
Output is correct |
3 |
Correct |
276 ms |
91492 KB |
Output is correct |
4 |
Correct |
269 ms |
91712 KB |
Output is correct |
5 |
Correct |
273 ms |
91764 KB |
Output is correct |
6 |
Correct |
247 ms |
90548 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
264 ms |
91388 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
264 ms |
90588 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
281 ms |
91820 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
283 ms |
92076 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
266 ms |
91564 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
272 ms |
91380 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
287 ms |
91756 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
291 ms |
92248 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
324 ms |
78784 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
142 ms |
33148 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
418 ms |
46388 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
1 ms |
212 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
0 ms |
212 KB |
Unexpected end of file - int32 expected |