Girls Invitational '18 J3 - Ski Chair Challenge

View as PDF

Submit solution

Points: 5
Time limit: 2.0s
Memory limit: 64M

Problem types

Every winter break, Mackenzie students go on a trip to the Lyon ski resort. Ms. William and her students are all suited up and ready to get onto the ski lift. All chairs hold two people with a certain maximum weight. Help Ms. William determine the minimum number of chairs she needs in order to send up the maximum number of students.

Input Specification

The first line will contain an integer that indicates the maximum weight capacity, C (0 \le C \le 150), a chair can hold.

The second line will contain an integer, N (1 \le N \le 100), that indicates how many individuals need to be brought up the chairlift.

The next N lines contain integers that represent the weight, W (1 \le W \le 100), of each individual.

Output Specification

Output the minimum number of chairs needed to send up the maximum number of students. Then, on the next line, output YES if there is any student(s) too heavy to be brought up by the ski lift and NO if all students are able to be brought up the mountain.

Sample Input 1

18
6
1
9
18
16
12
5

Sample Output 1

4
NO

Sample Input 2

34
3
30
38
1

Sample Output 2

1
YES

Comments

There are no comments at the moment.