This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]<<" ";
}
}
Compilation message (stderr)
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:39: 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |