Comments

You can use merge Sort Tree to solve this problems. Here you can see sample code of merger sort tree

I quit .

I enjoy Codeforces comment section more than Facebook. But what's happened today!! Almost 3 hours past and only 2 comments.

On DakDak → Personal Goal, 6 years ago
0

It took me one year to become pupil.I still can remember how much glad I was on that time. And Best wishes for you.

My little progress came when I start doing contest regularly.And If the contest was good that's good , if bad then it works as motivation to solve more problems and do good in later contest.So participating in regular contest is a very important part.

Online courses are unnecessary..Just solve problems..read editorials..see others solution..most importantly give time on that.

Is there any speciality with this problem Or you just loved that !

I think , I am late if compare with you, I started both coding and competitive programming at the age of 23 . Before that I didn't knew that what coding is . But I love this and trying my best.

+3

Truly said — I become more excited when I see the score distribution like this way..

Consider the following graph 4 1 2 2 3 3 4 then subtree of 1 is 2 3 4,subtree of 2 is 3 4 and subtree of 3 is 4 . then you are given some value of b and c . if value of b is 1 and value of c is 0 then you can shuffling between them ,and at the mean time you will consider the cost of the parent which cost is less. suppose you can shuffling node ( 2 , 4 ) or ( 3 , 4 ) .but the cost of 2 is 10 and 3 is 20 . so you will choose 2 as parent . and you will perform dfs and track down the minimum cost . To understand better you can watch this solution : https://codeforces.me/contest/1363/submission/82224132

I love the way you guys made this editorial. The concept of Key Idea and Detailed Explanation was really good .

That really wonders me how you think in that much easier way.

I become expert today for the first time..That's a great feeling .

0

I don't get the points why too many arguments against the division-4 . If It's too easy for you then make a race to finish all the problems in the shortest time and enjoy the contest or skip that.

Contest and Ramadan ... Both are enjoyable...

Tomorrow is a great day.. Make a contest..take 2 hours rest..Then again...Boom.. Feeling very much excited...

-13

Div-3 is Love... True Love... Pure Love...

Multiple contest in a Queue.. Thanks codeforces ...

On tourist → Codeforces Global Round 5, 7 years ago
-52

Everyone is too much excited for the contest because of tourist.... I am also excited and also frightened about the difficulty level... Anyway hope this will be interesting...

And you are going to get more up-vote Mr.PaPaSmurf

Yeah..Learn from today... But It made a lose to me..

At first full input need to be taken.. If the code can't take full input ... How the problem can be Ac...!! correct ans or not is the later priority... I got 50 negative for this in hacking phase... ****

0

Finally Div-3... Want more contest of Div-3.. In fact one in every week....

The problems in ( Div-1 & Div-2 ) combined contest are always interesting....

+15

My Final exam is going on... But I won't miss div-3.. Div-3 is love..

-34

That means It's also a tricky part... You guys makes me disappinted..

-34

After this contest my final exam will be started....But I will keep doing contest

Hmmm..

sorry for us

how much you understand?

I am not being able to understand the question of Div-2 (C) Hide and Seek... please someone explain me the question??

-19

I can only handle A,B,C after contest.Bt during contest time I was a great looser

On MikeMirzayanov → Happy 2019 Year!, 8 years ago
-9

I just want to be expert in this year.

I think that was Sarcasm..because everybody knows that tourist is the best...

On Mobinteymoori → Question 158B taxi, 8 years ago
0

package Practice;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int a,n,sum=0,c1=0,c2=0,c3=0,c4=0;
    n=input.nextInt();

    for (int i = 0; i < n; i++) {
        a=input.nextInt();
        switch (a) {
            case 1:
                c1++;
                break;
            case 2:
                c2++;
                break;
            case 3:
                c3++;
                break;
            default:
                c4++;
                break;
        }
    }
    sum=sum+c4;
    c4=0;

    sum=sum+(c2/2);
    c2=c2%2;

    if(c1>=c3){
    sum=sum+c3;
    c1=c1-c3;
    c3=0;
    sum=sum+(c1/4);
    c1=c1%4;
    if((c1+(c2*2))<=4 && (c1+(c2*2))>0){
    sum++;
    c1=0;
    c2=0;
    }else if(c1==3 && c2==1){
    sum=sum+2;
    c1=0;
    c2=0;
    }
    }

    else if(c1<c3){
    sum=sum+c1;
    c3=c3-c1;
    c1=0;
    sum=sum+c3+c2;
    }

    System.out.println(sum);


}

}

Hope you will get this.