comingsoon.cpp's blog

By comingsoon.cpp, history, 6 weeks ago, In English

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?

  • Vote: I like it
  • -5
  • Vote: I do not like it

»
6 weeks ago, # |
  Vote: I like it +1 Vote: I do not like it

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;

                }
            }
        }
    }
  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +3 Vote: I do not like it

    Thanks a lot bro. I really do not know how this works honestly. Care to explain a little bit more?

»
6 weeks ago, # |
  Vote: I like it +8 Vote: I do not like it

you should be executed for writing code like this

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    What's the problem with how i write code?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      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.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    is it his -=, != and so on lol those me, ne ? hahahahhaha