Que : “https://codeforces.com/contest/1407/problem/A”
solution : “Submission #92287594 - Codeforces”
Solution code(in short) -
while(t--) {
lli n;
cin>>n;
lli a[n];
scanarr(a,n);
lli cntone = 0 , cntzero= 0;
loop(i,n)
{
cntone += (a[i]==1);
cntzero += (a[i]==0);
}
if(cntone>(n/2))
{
cntone -= (cntone%2);
print(cntone);
loop(i,cntone)
cout<<1<<" ";
}
else
{
print(n/2);
loop(i,n/2)
cout<<0<<" ";
}
print("");
}
on test case
1
4
0 1 1 0
It gives -
2
0 0
but isn’t this wrong , bcz in question , they said The elements that you remove don’t have to be consecutive.