### comingsoon.cpp's blog

By comingsoon.cpp, history, 4 weeks ago,

Tried to solve the last div2 B 1993B - Parity and Sum, my approach happens to be similar to the editorial but some how my solution 274988685 fails, can anyone please enlighten me on what i might be missing?

• -5

 » 4 weeks ago, # |   +1 Add a flag to the loop where you find the number of operations. If you have to use the operation and the number of odds does not change, then it is optimal to use it for the largest even number. Now, the largest odd number is always greater than all the even numbers. Edit the second loop to this: bool flag=0; for(ll i = 0; i < n; i++){ if(i < anc){ if(!(a[i]%2)){ cnt pe 1; ev pe a[i]; } }else{ if(!(a[i]%2)){ if(ev > a[i] || flag){ cnt pe 1; ev pe a[i]; }else{ cnt pe 2; ev pe a[i]; flag=1; } } } } 
•  » » 4 weeks ago, # ^ |   +3 Thanks a lot bro. I really do not know how this works honestly. Care to explain a little bit more?
 » 4 weeks ago, # |   +8 you should be executed for writing code like this
•  » » 4 weeks ago, # ^ |   0 What's the problem with how i write code?
•  » » » 4 weeks ago, # ^ |   0 The code has few problems which I noticed and did not like. 1. You have used define for some of the most popular and most used operators in C++. You will regret your code writing skill if you have to switch your computer or coding language. 2. You have written multiple statements in a single line. What did you want? A one liner code or just lazy to use Return/Enter key? 3. You have assigned variable names too randomly (At least I wasn't able to figure out their role by their names). Even if you had done in the contest, while asking to debug you should have written the same code but with some meaning in the variable name to make your code easy to debug.
•  » » 4 weeks ago, # ^ |   +1 is it his -=, != and so on lol those me, ne ? hahahahhaha