#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define MOD 1000000007
#define INF 1000000
#define mp make_pair
#define ll long long
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef map<ll,ll> mii;
#define it(x) x::iterator
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define gcd __gcd
int main(){
int n, k;
cin>>n>>k;
int b[30] = {};
int a[n];
int mina = 30-(n+k-1);
FOR(i,0,n){ cin>>a[i]; b[a[i]]++; }
int tot = 0;
FOR(i,0,n) tot+=(1<<(a[i]));
int remainingbin = ((1<<30)-tot);
int remaining=-1;
while(remainingbin>0){
remaining++;
remainingbin/=2;
}
bool done = false;
if(!done && n>=2 && (a[0]<=a[1] && remaining<=a[0] || a[0]>=a[1] && remaining>=a[0])){
cout<<remaining<<" ";
done = true;
}
cout<<a[0]<<" ";
for(int i=1;i<n;i++){
if(!done && (remaining>=a[i-1] && a[i]>=remaining || remaining<=a[i-1] && a[i]<=remaining)){ cout<<remaining<<" "; done = true;}
cout<<a[i]<<" ";
}
cout<<endl;
}
Compilation message
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:34:37: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(!done && n>=2 && (a[0]<=a[1] && remaining<=a[0] || a[0]>=a[1] && remaining>=a[0])){
~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
zalmoxis.cpp:40:40: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
if(!done && (remaining>=a[i-1] && a[i]>=remaining || remaining<=a[i-1] && a[i]<=remaining)){ cout<<remaining<<" "; done = true;}
~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
zalmoxis.cpp:23:9: warning: unused variable 'mina' [-Wunused-variable]
int mina = 30-(n+k-1);
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
356 ms |
6520 KB |
not a zalsequence |
2 |
Incorrect |
355 ms |
6392 KB |
not a zalsequence |
3 |
Incorrect |
353 ms |
6384 KB |
not a zalsequence |
4 |
Incorrect |
361 ms |
6364 KB |
not a zalsequence |
5 |
Incorrect |
349 ms |
6392 KB |
not a zalsequence |
6 |
Incorrect |
378 ms |
6376 KB |
not a zalsequence |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
348 ms |
6448 KB |
Unexpected end of file - int32 expected |
2 |
Incorrect |
350 ms |
6396 KB |
Unexpected end of file - int32 expected |
3 |
Incorrect |
349 ms |
6268 KB |
Unexpected end of file - int32 expected |
4 |
Incorrect |
375 ms |
6392 KB |
Unexpected end of file - int32 expected |
5 |
Incorrect |
349 ms |
6392 KB |
Unexpected end of file - int32 expected |
6 |
Incorrect |
350 ms |
6432 KB |
Unexpected end of file - int32 expected |
7 |
Incorrect |
353 ms |
6392 KB |
Unexpected end of file - int32 expected |
8 |
Incorrect |
362 ms |
6356 KB |
Unexpected end of file - int32 expected |
9 |
Incorrect |
282 ms |
5288 KB |
Unexpected end of file - int32 expected |
10 |
Incorrect |
107 ms |
2168 KB |
Unexpected end of file - int32 expected |
11 |
Incorrect |
175 ms |
3320 KB |
Unexpected end of file - int32 expected |
12 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |
13 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |
14 |
Incorrect |
2 ms |
256 KB |
Unexpected end of file - int32 expected |