this hurts bad, really bad, did the same
https://www.codechef.com/viewsolution/37286779
I donât understand why middle 2 testcases go WA, is there a bug in the code or a faulty testcase?
else if ((m) / 2 < m2)
Try chaging that to m <= 2*m2
.
Where are the editorial of other question? Please upload them too
try changing that to m<=2*m2
https://www.codechef.com/viewsolution/37287301
Help, i wasted my entire time trying to get that 1 subtask right but i canât figure out how
https://www.codechef.com/viewsolution/37271549
I am unable to find any test case for which my solution is wrong .Can anyone plz help me by finding any mistake or giving any testcase .
Not working bro, m is odd so = doesnât matter
Thatâs weird. When I made the change, it worked.
try this
1
11
1 0 0 0 1 0 0 0 0 01
ans-No
I spent almost 2 hrs on this problem.Just missed by the margin.
My solution: CodeChef: Practical coding for everyone
please can someone help with the code.
#include
#include
#include
using namespace std;
int main(){
int t;
cin>>t;
while(tâ){
int n;
vector v;
cin>>n;
int a[n];
for(int i=0;i<n;i++){
cin>>a[n];
}
for(int i=0;i<n;i++){
if(a[i]==0){
int j=i,size=0;
while(a[j]==0&&j<n){
size++;
j++;
}
i=j;
v.push_back(size);
}
}
if(v.size()==0){
cout<<"No"<<endl;
}
else{
if(v.size()==1){
if(v[0]%2!=0){
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
else{
sort(v.begin(),v.end());
int i=v.size()-1;
if(v[i]%2==1&&(v[i-1]<(v[i]+1)/2))
{
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
}
}
}
1
11
1 0 0 0 0 0 1 0 0 0 1
Your code gives Yes, answer should be no.
ELOMAX was super easy ! Just implement it
Thanks! Got it finally
Is it just doing what the problem statement says?
Try out this case:
1
11
1 0 0 0 0 0 1 0 0 0 1
CodeChef: Practical coding for everyone still wrong?
can you tell me where do i need to make a change