Entrance test of Tyvj2016 Winter camp in North Qing

Source: Internet
Author: User

P4744A ' s problem (a) Time: 1000ms/Space: 655360kib/java class name: main background

Winter School Entrance test, every three days to settle the results. Participate in benefits

Describe

This is a subject of background, small A is also a person with a story. But unfortunately the paper is too small, small a can not tell the story in detail to everyone. Maybe small a himself also can not tell his own story, because if it is clear, there is no such a problem ...

The problem with small A is this, it found n different jobs, I work every month to have AI wages, each job needs a small a 8 hours a day, work 7 days a week. Little A would like to know the number of jobs with the highest cost performance (one months ' wages divided by the total length). If there are multiple copies, the output number is the smallest.

Input format

The first row is a number n, which indicates that there is n job.

The next n number represents AI.

Output format

Output a number to indicate the answer.

Note

Input sample

5

3 3 4) 5 5

Output sample

4

Data range

For data n<=100,1<=ai<=1000 of 100%.

"Water problem not much to say series"

#include <iostream>using namespacestd;intn,a[ the];intMain () {CIN>>N;  for(intI=1; i<=n;i++) Cin>>A[i]; intj=1;  for(intI=2; i<=n;i++)        if(A[i]>a[j]) j=i; cout<<J; return 0;}
P4745B ' s problem (b) Time: 1000ms/Space: 655360kib/java class name: main background

Winter School Entrance Test

Describe

Title Description

Small b living in a very strange country, the value of the country's money can only be 25,50,100. Little B is doing social practice recently, this time it chooses to do this thing in a restaurant. But today an interesting thing happened, this thing is like this, the restaurant everyone in the queue to buy rice, careless dozen aunt forgot to bring change, and all the people lined up to eat only a piece of money.

Specifically, I have a person with a denomination of money for AI, for the sake of convenience, we stipulate that everyone wants to buy a lunch box worth 25 yuan. Aunt seemed overwhelmed. Clever Little B thought of a method, let bring 25 yuan first buy rice! So the aunt has more change to find some more face value of the money.

But it is still possible for some people to find no change, and little b wants to know if there is a queueing scheme that can get change for everyone. If output "YES" is feasible, output "NO".

Input format

The first line is a number n, which means that there are n people who want to buy a meal.

The next line of N is the number of AI, which represents the denomination of the money the person carries.

Output format

Output "YES" or "NO".

Note

Input sample

3

25 50 100

Output sample

NO

Data range

For 100% of data n<=100,ai=25 or 50 or 100.

Ideas

All the people take the money from small to large order, you can also find

If this person is 25 yuan, then do not need the change, my wallet is more than 25 yuan

If this person is 50 yuan, then there is only one solution, with a 25 yuan and he exchange, if at this time I do not have 25 yuan so "no" (because I have put people from the big to the small row in the order, so the latter people can not have 25 of the money)

If this guy's got $100, there's two ways.

With a 50 and a 25 to trade with him, ask B25>=1,b50>=1

With three sheets of 25 to exchange with him, ask B25>=3

Does not meet the requirements

#include <iostream>#include<algorithm>using namespacestd;intn,a[ the],b25,b50,b100;BOOLFlag;intMain () {CIN>>N;  for(intI=1; i<=n;i++) cin>>A[i]; Sort (a+1, a+n+1);  for(intI=1; i<=n;i++)    {        if(a[i]== -) b25++; if(a[i]== -)        {            if(b25==0) flag=1; ElseB25--, b50++; }        if(a[i]== -)        {            if(b25==0) flag=1; Else{                if(b25>=1&&b50>=1) {B25--;b50--; Continue; }                Else if(b25>=3) {B25-=3; Continue; }                Elseflag=1; }        }    }    if(flag==0) cout<<"YES"; Elsecout<<"NO"; return 0;}

Entrance test of Tyvj2016 Winter camp in North Qing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.