Problem A. Arya Input file: Standard Input Output file: Standard Output Time Limit: 1 Second Memory Limit: 256 Megabytes

Problem A. Arya Input file: Standard Input Output file: Standard Output Time Limit: 1 Second Memory Limit: 256 Megabytes

TAMU Team Programming Contest TAMU, February, 24 2018 Problem A. Arya Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Arya Stark wants to take dancing lessons1. Given how much she loves “dancing,” she wants to practice with her dancing master as much as possible. Her dancing master will be around for n days, and he will be available for training some h number of hours each day. As Arya usually has to skip some important banquet or tournament in order to practice, her father will only let her practice on k of the n days. How many hours can Arya practice in total, if she chooses her days optimally? Input The first line of input consists of two integers, n and k (1≤k≤100), representing the number of days Arya’s dancing master is available, and the number of days Arya is allowed to practice. Each of the next n lines contains a number h (1≤h≤10) describing the number of hours of the given practice. Output Output a single integer giving the maximum number of hours Arya can spend practicing. Example standard input standard output 7 3 23 6 1 2 10 2 7 5 Note 1: They’re actually sword fighting lessons, but that’s a secret kept between Arya and her father In the first test case, since Arya can practice on 3 days, she will choose the first, fourth, and sixth days, for a total of 6+10+7=23 hours of practice. Page 1 of 15 TAMU Team Programming Contest TAMU, February, 24 2018 Problem B. Bran Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Bran Stark loves climbing the towers of Winterfell. The towers are arranged in a rectangular grid of m rows and n columns, with each tower having a different height h units. Bran starts at the tower in the top left corner. From a given position, Bran can climb to any adjacent (but not diagonal) tower, as long as the height of the adjacent tower is within k units of the height of his current tower. Given the layout of the towers of Winterfell, determine the maximum height to which Bran can climb. Input The first line of input contains three integers: m, n, and k, representing the number of rows on the grid, the number of columns on the grid, and the height difference which Bran can climb (1≤m, n, k≤100). The following m lines each contain n integers, representing the height (1≤h≤100) of each tower on the grid. Output Output one integer, containing the maximum height to which Bran can climb. Examples standard input standard output 3 4 2 8 3 1 2 4 5 9 6 5 7 5 8 2 3 2 10 25 25 36 12 21 18 27 Note In the first test case, Bran starts his journey on the tower of height 3. He climbs east, east, east, south, west, then south, to reach the tower of height 8. It is impossible for Bran to climb to the tower of height 9, because it is a minimum of 3 units away from the adjacent towers, which is greater than the k of 2. In the second test case, Bran starts at the tower with the height of 25 and cannot climb to either of the two adjacent towers, which have a height difference greater than the k of 10. Page 2 of 15 TAMU Team Programming Contest TAMU, February, 24 2018 Problem C. Cersei Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Cersei Lannister, queen of the Seven Kingdoms, has encountered something of a predicament. Due to the careless spending of her husband1, the crown has taken on a substantial amount of debt. Cersei Lannister always pays her debts. The crown has received loans from the Iron Bank of Braavos, each with a fixed interest rate. An interest rate of r means that for every 100 gold pieces the crown owes, its debt increases by an additional r gold pieces each year. As the Iron Bank of Braavos likes to be very accurate, they keep track of their loans with perfect precision, meaning that balances can be decimal values. Given the amounts and dates of the loans the crown has received, determine its total amount of debt. Input The first line of input consists of two integers, n and r (1≤n, r≤10), representing the number of loans the crown has received and the interest rate throughout the Seven Kingdoms. Each of the next n lines contains two positive integers no greater than 100, containing the original amount of money in the loan and the number of years ago it was made. Output Output a floating point number containing the crown’s current amount of debt. Your answer will be considered correct if its absolute or relative accuracy is within 0.0001 of the correct answer. Example standard input standard output 3 5 284.812567266 100 7 40 1 80 5 Note 1: King Robert’s main expenditure is prize money for tournaments, which he loves to watch. He doesn’t really have any other vices. Page 3 of 15 TAMU Team Programming Contest TAMU, February, 24 2018 Problem D. Daenerys Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes In celebration of her recent marriage, Daenerys Targaryen has been given dragon eggs as a gift! Since no one has ever been able to hatch a dragon in over a century, the eggs were given to her merely as a decoration. But Daenerys has other plans. Daenerys knows that dragon eggs will hatch when they’re set on fire, just as long as the eggs are old enough. Specifically, they will hatch if and only if they are at least p years old. Given the age of each of Daenerys’s dragon eggs, determine how many of them are old enough to hatch, once they’re set on fire. Input The first line of input consists of two integers, n and p (1≤n, p≤100), representing the number of dragon eggs and the age at which dragon eggs hatch. Each of the next n lines contains a number k (1≤k≤100) describing the age of a given dragon egg. Output Output a single integer giving the number of dragons that will hatch from the dragon eggs. Example standard input standard output 3 50 2 60 40 50 Page 4 of 15 TAMU Team Programming Contest TAMU, February, 24 2018 Problem E. Eddard Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Lord Eddard Stark, son of Rickard Stark, Lord of Winterfell and Warden of the North, has been feeling rather cold lately. He recalls the old words of House Stark, “Winter is coming,” and wonders whether or not this is the case. For the past few days, Lord Stark has kept track of whether he felt warm or cold. If Lord Stark has felt cold three days in a row, it must be the case that winter is coming. Otherwise, it will be another year of summer. Can you determine which outcome is true? Input The first line of input is the number of temperature recordings, n (3≤n≤10). Each of the next n lines contains one lowercase word describing the temperature: “warm” or “cold”. Output If there are three consecutive cold days in the recordings, then print “Winter is coming”. If not, then print “Another year of summer”. Examples standard input standard output 5 Winter is coming warm cold cold cold warm 7 Another year of summer cold cold warm cold cold warm cold Page 5 of 15 TAMU Team Programming Contest TAMU, February, 24 2018 Problem F. Free Folk Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 256 megabytes Far north of the seven kingdoms are the lands beyond the Wall, where the Free Folk live. For thousands of years, the Free Folk have warred against the men of the Night’s Watch, to little avail. But recently, the Free Folk united under the king beyond the wall, who will march them to their victory. Their army is quite formidable, consisting of three types of soldiers: humans, giants, and mammoths. The king beyond the wall has ordered a specific battle formation for the Free Folk. The Free Folk will organize themselves in a rectangle with a width of 3 units and a length of n units. Their formation can include any number of humans, giants, and mammoths. A human takes up a 1x1 square, a giant takes up a 2x2 square, and a mammoth takes up a 3x3 square. Every square in the grid must be filled. The king beyond the wall would like to know how many possible configurations of his army exist. Two configurations are considered different if any given position between them has a different type of soldier. As the number of possible configurations can be very large, it should be output modulo 1000000007 (109+7). Input Input consists of a single integer, n (1≤n≤106), representing the length of the formation. Output Output a single integer giving the number of possible configurations of the army, modulo 1000000007 (109+7). Example standard input standard output 4 13 Note In the first test case n = 4 and the output is 13. All 13 possibilities are shown below.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    15 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us