Input File: archin.txt
Output File: archout.txt
Time Limit: 1 second
When you were young, you were awe-struck by the battle scene in The Lord of the Rings: The Two Towers. From then on, you were determined to become the greatest archer of all time. After years of training, you are finally at the International Archery Olympiad (IAO), in Auckland.
On each of the two days of the IAO, all contestants are given a score and ranked by that score. After the second day of competition, all contestants are given an overall score equal to the sum of their two scores and their overall rank is then calculated from this.
Katniss | Legolas | Link | Merida | Robin | |
Day 1 Score | 50 | 70 | 20 | 40 | 0 |
---|---|---|---|---|---|
Day 1 Rank | 2 | 1 | 4 | 3 | 5 |
Day 2 Score | 30 | 20 | 40 | 50 | 40 |
Day 2 Rank | 4 | 5 | 2 | 1 | 2 |
Overall Score | 80 | 90 | 60 | 90 | 40 |
Overall Rank | 3 | 1 | 4 | 1 | 5 |
A contestant's rank is equal to the number of competitors with strictly greater scores than theirs, plus one. In the above example, there are two overall scores strictly greater than Katniss's, so her overall rank is (2+1)=3. There are no overall scores strictly greater than Legolas's, so his overall rank is (0+1)=1. (Notice that Legolas and Merida are both ranked 1, as no one has a strictly greater score than either of them.)
Sick with anticipation of the results, you sneak a look at a judge's laptop. The scores aren't shown, nor is your overall rank, but you do manage to glimpse your first-day rank and your second-day rank. You want to work out what your overall rank could be.
Your task is to write a program which, given the number of contestants in the IAO and your rank on each day, determines your best and worst possible overall rank.
Your program should read from the file . The first and only line of input will contain three space-separated integers in this order:
Your program should write to the file . Your output file should contain one line with two integers, with exactly one space between them. The first integer is your best (i.e. smallest number) possible overall rank and the second integer is your worst (i.e. largest number) possible overall rank.
Input File: frogin.txt
Output File: frogout.txt
Time Limit: 1 second
Bazza and Shazza do not like bugs. They wish to clear out all the bugs on their garden fence. They come up with a brilliant idea: they buy some sugar frogs and release them near the fence, letting them eat up all the bugs.
The plan is a great success and the bug infestation is gone. But strangely, they now have a sugar frog infestation. Instead of getting rid of the frogs, Bazza and Shazza decide to set up an obstacle course and watch the frogs jump along it for their enjoyment.
The fence is a series of N fence posts of varying heights. Bazza and Shazza will select three fence posts to create the obstacle course, where the middle post is strictly higher than the other two. The frogs are to jump up from the left post to the middle post, then jump down from the middle post to the right post. The three posts do not have to be next to each other as frogs can jump over other fence posts, regardless of the height of those other posts.
The difficulty of an obstacle course is the height of the first jump plus the height of the second jump. The height of a jump is equal to the difference in height between its two fence posts. Your task is to help Bazza and Shazza find the most difficult obstacle course for the frogs to jump.
Your program should read from the file . The file will describe a single fence.
You are guaranteed that there will be at least one valid obstacle course: that is, there will be at least one combination of three fence posts where the middle post is strictly higher than the other two.
Your program should write to the file . Your output file should contain one line with one integer: the greatest difficulty of any possible obstacle course.
Input File: savein.txt
Output File: saveout.txt
Time Limit: 1 second
The United Bakers of Australia (UBA) is once again in hot water. Profits have been crumbling recently due to a new tax on an invisible poisonous ingredient underpinning cake manufacturing. Rather than adapt their recipes to use healthier alternatives, the UBA has employed analysts from PwC (People with Cupcakes) to find a way to cut costs.
Upon inspection of UBA's purchasing practices, the analysts found that when a group of ingredients is ordered, the cost of the group is rounded to the nearest 5 cents. That is, a group's cost is the multiple of 5 that has the smallest difference with the sum of its ingredient costs.
For instance, two items costing 32c and 47c can be bought in separate groups for 30c and 45c, or 75c in total, whereas purchasing them in one group together would cost 80c (rounded up from 79c).
Your task is to put the required ingredients into groups for purchasing in order to minimise their total cost.
Your program should read from the file . The file will describe a single list of ingredients.
Your program should write to the file . Your output file should contain one line with one integer: the minimum total cost for the ingredients.
© 2024. All Rights Reserved. 沪ICP备2023009024号-1