Finalists
Time limit3sMemory limit1024 MB
Given the World Finals slot count N and six regionals' statistics, compute how many slots the Taiwan regional receives under the site-score allocation rules.
- Level
Easy3 of 10
- Topics
- Implementation, Sorting, Simulation
- Solved
- No attempts yet
Problem
Frank is trying his best to win a slot in Asia Pacific to the World Finals. But he could not find the selection rules to estimate his chance. Last night, Frank's coach found the following document.
=====================================================================
World Finals team selection rules from Asia Pacific (2022 cycle)
Due to COVID-19 outbreak, this year's Asia Pacific rules will
again be quite different from those of usual years. The plan
for having an Asia Pacific semi-final contest (play-off contest)
has been cancelled and postponed to the next year.
Only the following six regionals will be held this year.
Ho Chi Minh, Vietnam
Jakarta, Indonesia
Manila, Philippines
Seoul, Korea
Taoyuan, Taiwan
Yokohama, Japan
We have set a team participation rule. This rule is a special one
for this year (2022 cycle) only.
Teams from a hosting country (Indonesia, Japan, Korea, Philippines,
Taiwan and Vietnam) can only join the regional held in their own
country. Universities from non-hosting countries should choose a
regional. Note that all teams from a single university have to join
the same regional.
World Finals team selection rules are as follows.
Apply Steps A1 through A4 below in this order.
A1. Define the site score of a regional as follows.
0.56 * number of universities in regional
+ 0.24 * number of teams in regional
+ 0.14 * number of universities in preliminary contests
+ 0.06 * number of teams in preliminary contests
+ 0.3 * number of foreign teams
Only teams or universities solving at least one problem are counted.
A2. Sort our six regionals according to their site scores.
A3. Let N be the number of World Finals slots given from the ICPC
Headquarters. Until the sum of the number of allocated slots
reaches N, allocate slots to regionals, one by one, in the
descending order of their site scores. When all six regionals
are allocated one slot each, continue from the regional with the
highest site score in the round robin fashion.
A4. For each regional, let M be the number of slots allocated to the
regional through the step A3. Select the M highest ranked
universities. The team with the highest rank in the university
is automatically selected.
=====================================================================
Assume that the document is the final selection rules for teams from Asia Pacific. Given and the necessary numbers to calculate the site scores, write a program that computes the number of slots allocated to Taiwan.
Input
There are seven lines in the input. The first line contains , the number of World Finals slots given from the ICPC Headquarters. Each of the following six lines consists of one string and five non-negative integers , , , , , separated by spaces.
is the country hosting a regional contest. is the number of teams solving at least one problem in the preliminary contests hosted by the country . is the number of universities solving at least one problem in the preliminary contests hosted by the country . is the number of teams solving at least one problem in the regional contest hosted by the country . is the number of universities solving at least one problem in the regional contest hosted by the country . is the number of foreign teams solving at least one problem in the regional hosted by the country .
Output
Output the number of slots allocated to Taiwan.
Constraints
- is at least and at most .
- Each line has a distinct .
- is one of the following countries: Vietnam, Indonesia, Philippines, Korea, Taiwan, and Japan.
- You may assume that distinct regional contests have different site scores.
- The size of an input file is no more than 64 kilobytes.
Hint
The document in the problem statement is not official. Please refer to Prof. CJ Hwang's blog https://icpcasia.wp.txstate.edu/ for the official rules.