Блог пользователя comingsoon.cpp

Автор comingsoon.cpp, история, 6 недель назад, По-английски

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
  • Проголосовать: не нравится

»
6 недель назад, # |
  Проголосовать: нравится +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;

                }
            }
        }
    }
  • »
    »
    6 недель назад, # ^ |
      Проголосовать: нравится +3 Проголосовать: не нравится

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

»
6 недель назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

you should be executed for writing code like this

  • »
    »
    6 недель назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    What's the problem with how i write code?

    • »
      »
      »
      6 недель назад, # ^ |
        Проголосовать: нравится 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.

  • »
    »
    6 недель назад, # ^ |
      Проголосовать: нравится +1 Проголосовать: не нравится

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