Your temp variable just stores the count of zeros in last zero segment. It is fine for Sub-task 1 but it actually makes no sense. I would suggest you to read editorial ^^.
Try this case:
1
13
1 0 0 0 1 0 0 0 1 0 0 0 1
Sorry that i cannot point out the mistake in your code. if you could explain the logic then i might be able to help.
1
10
1 0 0 1 0 0 0 0 0 1
Your code giving wrong answer for this
ok, here it goes
i added all the zero lengths into my multiset.
then i took the largest and second largest then checked if :
( largest >> 1 ) > (second_largest) cout << "no"
this is previous wrong after your test case i updated it to
( largest + 1 >> 1) > (second_larget cout << "no"
rest is quite same to editorial if largerst is odd cout << âYESâ else ânoâ
Shouldnât > be < here?
1
4
0 0 0 1
Your code gives wrong answer for this
1
7
1 0 1 0 0 0 1
Your code gives wrong answer for this case
OMG thank you!!
Doesnât the constraints say A1 = An = 1 though?
You are correct. I am sorry I ignored the constraint, although my code managed that.
You can try
1
5
1 0 1 0 1
I am guessing this part of your code caused the error
if(zerocount == 2)
{
if(n%2 == 0)
cout << âNo\nâ;
else
cout << âYes\nâ;
}
what does âgamesâ mean in prerequisite ?
I want to know time complexity of my code. I used two loop and solution should be in O(N).
Here is my code solution
Yeah you can check my solution i just implemented everything and it was 100pts
O(NlogN) as U have used sort() functionâŚ
Cool, I thought that Iâd get TLE so I didnât try. That was stupid.
Yeah , that makes sense. Thanks again
Thanks, I am thinking about inner while loop. Is it less then logn?
Somebody please help ! Idk whats wrong with the code⌠the logic though is perfect.
https://www.codechef.com/viewsolution/37291601
Thank You so much Bro
Your code is wrong for n=1⌠Please check at input
1
1
0
Here answer is yes but yours gives NoâŚ
Values of m and m2 remains same while m should be 1âŚcorrect it