Why Did APC Become a Subtask Contest?
InterviewTime limit1sMemory limit512 MB
Given N problems each with an easy and hard difficulty and a solve limit K, find the maximum score Hyunjung can earn with skill L. Each problem's easy part is worth 100 and the hard part adds 40, and solving the hard part counts as one problem.
- Level
Easy3 of 10
- Topics
- Greedy, Sorting, Array, Implementation
- Solved
- No attempts yet
Problem
In 2019, the Ajou Programming Contest (APC) was held once again! Junpyo, who took over as APC's head this year, fell into deep worry while preparing the problems. The participants in APC are so diverse that setting the difficulty of the problems is very hard.
APC draws many students who are not used to programming contests and many who are not majors, so it needs a difficulty curve that everyone can solve or attempt. It also has to have the discriminating power of a selection round for the 10 school representatives who will compete in the 'Gyeongin region 6 university联合 programming contest, shake!', and since an Open Contest where outsiders can compete separately runs at the same time, he also wants to prevent the so-called 'veterans' from conquering the contest in under an hour. On top of that, the APC problem setters Junpyo, Manyoung, Hyunjung, and Junseo worked very hard preparing the problems, so they hope participants will read every problem at least once.
Greedy Junpyo, after much thought, proposed one solution to satisfy all these many needs. Split each problem into an easy version and a hard version through constraints, and run the contest as a subtask contest that gives partial credit for solving only the easy version. He also intends to arrange the problems in order of the easy version's difficulty.
Preparing problems this way lets people who are not used to programming contests follow along from the front and attempt problems without spending time hunting for easy ones, keeps the discriminating power for selecting school representatives through the hard versions, and fulfills the setters' wish that every problem be read!

<!-- The story below is fiction. -->
Hyunjung has a wish to participate in APC at least once. But since this wish has never come true and never will, Hyunjung has a habitual saying.
- Hyunjung: Ah~~ If only I had participated in APC, I'd be getting prize money~~~~~
- Junpyo: ... I don't think that's true?
Junpyo, annoyed by Hyunjung's baseless confidence, wants to tell Hyunjung her expected score based on the problem difficulties evaluated during preparation, and help her accept reality.
Hyunjung has skill L and can solve problems of difficulty less than or equal to L. Also, since she codes slowly, the contest time is insufficient, so she cannot solve more than K problems. Solving the easy version of a problem gives 100 points, and solving the hard version gives 40 more points for 140 points. Solving the hard version also solves the easy version, so it counts as solving one problem.
Tell us the maximum score Hyunjung could have earned if she had participated in APC.
Input
The first line gives the number of problems N, Hyunjung's skill L, and the maximum number of problems Hyunjung can solve during the contest K.
From the second line, N lines follow, giving in order the difficulty sub1 of the easy version and the difficulty sub2 of the hard version of problems 1 to N.
Output
Output the maximum score Hyunjung could have earned if she had participated in APC.
Constraints
- 1 ≤ N ≤ 100
- 1 ≤ L ≤ 50
- 1 ≤ sub1 ≤ sub2 ≤ 50
Hints
Samples 2 and 3 do not appear in subtask 1.
Traditionally in APC, solving the easy versions first is good for mental health and stable scoring.