Problem D Daydreaming Stockbroker

Similar documents
Problem A. Jumbled Compass

Problem B Best Relay Team

The 2016 ACM-ICPC Asia China-Final Contest Problems

Problem Set 7: Network Flows Fall 2018

Integers. Chapter Introduction

11 + Entrance Examination Sample Paper 2 Mathematics Total Marks: 100 Time allowed:1 hour

Q i e v e 1 N,Q 5000

Primary 6 January Review 5

Addition and Subtraction

SERIES Addition and Subtraction

THEME: COMMUNICATION

1 Write the proportion of each shape that is coloured, as a fraction in its simplest form.

EDEXCEL FUNCTIONAL SKILLS PILOT. Maths Level 2. Chapter 1. Working with whole numbers. SECTION A 1 Place value and rounding 2. 2 Negative numbers 4

MTEL General Curriculum Mathematics 03 Multiple Choice Practice Test B Debra K. Borkovitz, Wheelock College

A few chessboards pieces: 2 for each student, to play the role of knights.

International mathematical olympiad Formula of Unity / The Third Millenium 2013/2014 year

What You Need to Know Page 1 HANG 10! Write addition and subtraction expressions that equal 10.

Problem A. First Mission

TEST 6. 12, 7, 15, 4, 1, 10, Circle all the odd numbers.

What You ll Learn. Why It s Important. Students in a grade 7 class were raising money for charity. Some students had a bowl-a-thon.

TEST (a) Write these numbers in order of increasing size. 12, 7, 15, 4, 1, 10, Circle all the odd numbers.

Empirical (or statistical) probability) is based on. The empirical probability of an event E is the frequency of event E.

Addition and Subtraction

Exploring Concepts with Cubes. A resource book

Number Line: Comparing and Ordering Integers (page 6)

Grade 6 Math Circles Combinatorial Games - Solutions November 3/4, 2015

satspapers.org Year 7 mathematics test

and Games Developing Numeracy Skills Using Visual Tools A Workshop by Trevor Calkins

Intermediate Mathematics League of Eastern Massachusetts

Measuring in Centimeters

State Math Contest 2018 Junior Exam

Part A (C) What is the remainder when is divided by 11? (A) 0 (B) 1 (C) 3 (D) 7 (E) 10 (A) 35 (B) 40 (C) 45 (D) 50 (E) 55

Meet #3 January Intermediate Mathematics League of Eastern Massachusetts

Fibonacci Numbers ANSWERS Lesson 1 of 10, work individually or in pairs

Chuckra 11+ Maths Paper 2

Problem A. Worst Locations

100 IDEAS FOR USING A HUNDRED SQUARE

IN THIS ISSUE. Cave vs. Pentagroups

Solving Problems. PS1 Use and apply mathematics to solve problems, communicate and reason Year 1. Activities. PS1.1 Number stories 1.

Spring 06 Assignment 2: Constraint Satisfaction Problems

Math 7 Mid-Winter Recess

Paper 1. Mathematics test. Calculator not allowed. satspapers.org. First name. Last name. School KEY STAGE TIER

Phrases for 2 nd -3 rd Grade Sight Words (9) for for him for my mom it is for it was for. (10) on on it on my way On the day I was on

2006 Canadian Computing Competition: Junior Division. Sponsor:

Grade 5 Math By Kelly McCown. Summer. NO PREP Math Packet

An Idea for a Project A Universe for the Evolution of Consciousness

MTEL General Curriculum Mathematics 03 Multiple Choice Practice Test A Debra K. Borkovitz, Wheelock College

Linear Functions Review

Problem A Rearranging a Sequence

AUTUMN 2016 GCSE 9-1 MOCK FOUNDATION PAPER 1 ALTERNATIVE VERSION

TUESDAY, 8 NOVEMBER 2016 MORNING 1 hour 30 minutes

1. Five cards are drawn from a standard deck of 52 cards, without replacement. What is the probability that (a) all of the cards are spades?

Problem Set 7: Games Spring 2018

Situations Involving Multiplication and Division with Products to 100

Eleventh Annual Ohio Wesleyan University Programming Contest April 1, 2017 Rules: 1. There are six questions to be completed in four hours. 2.

Grid in Answers to Data Questions

Problem Solving Problems for Group 1(Due by EOC Sep. 13)

Final Practice Problems: Dynamic Programming and Max Flow Problems (I) Dynamic Programming Practice Problems

Meet #5 March Intermediate Mathematics League of Eastern Massachusetts

CPM Educational Program

UNIT 2: RATIONAL NUMBER CONCEPTS WEEK 5: Student Packet

Problem solving Grade 4 GCSE 9-1

2. Approximately how many seconds are there in two-sevenths of a 2. seconds minute? Round your answer to the nearest second.

Input. Output. Examples. Note. Input file: Output file: standard input standard output

1. On a test Robert got twice as many answers correct as Chris, and three more correct than

GCSE 4370/03 MATHEMATICS LINEAR PAPER 1 FOUNDATION TIER

Instructions. Information. Advice

Name: Period: Date: 1. Which of the following graphs does not represent. 2. It is given that. What is A. B. C. D.

junior Division Competition Paper

UK Junior Mathematical Olympiad 2017

1 Summer Math Booklet

Organization Team Team ID# If each of the congruent figures has area 1, what is the area of the square?

Note ook Doodle Pillow

Reception Vocabulary bookmark. Reception Vocabulary bookmark. Adding and subtracting. Adding and subtracting

Please print legibly. School / Team. Names. Directions: Answers must be left in one of the following forms:

Module 2- A Functions A. 16, 18, 20, 22 B. 16, 19, 20, 21 C. 16, 20, 24, 28 D. 16, 22, 24, 26

2. A rectangle has a length of meter. The area is square meter. What is the width of the rectangle?

2. Attempt to answer all questions in the spaces provided in this book.

UNC Charlotte 2012 Algebra

Grade 3 NAPLAN preparation pack:

Math is Cool Masters

Winter Quarter Competition

Topic 8. Numerical expressions patterns & Relationships. Name. Test Date

Chapter 2 Integers. Math 20 Activity Packet Page 1

Paper 1. Calculator not allowed. Mathematics test. First name. Last name. School. Remember KEY STAGE 3 TIER 5 7

KSF selected problems Student

Unit 1, Lesson 1: What are Scaled Copies?

2005 Galois Contest Wednesday, April 20, 2005

Prepublication pages, envisionmath

Southeastern European Regional Programming Contest Bucharest, Romania Vinnytsya, Ukraine October 21, Problem A Concerts

Chuckra 11+ Maths Test 1

Grade 6 Math Circles Combinatorial Games November 3/4, 2015

CLASS - VIII. Time Allowed: 2 Hours Max. Marks: 100

STUDENT'S BOOKLET. Inclination: Explorations on Slopes Part 1. Contents. 1 Flights 2 The slope of a line. 3 How Tall are you? 4 Duplicating Squares

Thanks for downloading this product from Time Flies!

ACM ICPC World Finals Warmup 2 At UVa Online Judge. 7 th May 2011 You get 14 Pages 10 Problems & 300 Minutes

Grade 7/8 Math Circles Game Theory October 27/28, 2015

GCSE Mathematics Practice Tests: Set 6

2012 Math Day Competition

High-Impact Games and Meaningful Mathematical Dialog Grades 3-5

Transcription:

Problem D Daydreaming Stockbroker Problem ID: stockbroker Time limit: 1 second Gina Reed, the famous stockbroker, is having a slow day at work, and between rounds of solitaire she is daydreaming. Foretelling the future is hard, but imagine if you could just go back in time and use your knowledge of stock price history in order to maximize your profits! Now Gina starts to wonder: if she were to go back in time a few days and bring a measly $100 with her, how much money could she make by just buying and selling stock in Rollercoaster Inc. (the most volatile stock in Photo by liz west on flickr, cc by existence) at the right times? Would she earn enough to retire comfortably in a mansion on Tenerife? Note that Gina can not buy fractional shares, she must buy whole shares in Rollercoaster Inc. The total number of shares in Rollercoaster Inc. is 100 000, so Gina can not own more than 100 000 shares at any time. In Gina s daydream, the world is nice and simple: there are no fees for buying and selling stocks, stock prices change only once per day, and her trading does not influence the valuation of the stock. A The first line of input contains an integer d (1 apple d apple 365), the number of days that Gina goes back in time in her daydream. Then follow d lines, the i th of which contains an integer p i (1 apple p i apple 500) giving the price at which Gina can buy or sell stock in Rollercoaster Inc. on day i. Days are ordered from oldest to newest. the maximum possible amount of money Gina can have on the last day. Note that the answer may exceed 2 32. Sample 1 Sample 1 6 100 200 100 150 125 300 650

B. Bacteria Experiment time limit per test: 1.5 s memory limit per test: 256 MB input: standard input output: standard output A year after his bacteria experiment, Jason decided to perform another experiment on a new bacteria specie which evolves in a special way. The initial form of the bacteria can be considered as an undirected tree with N nodes in terms of graph theory. Every hour, an edge (x, y) is built if there exists a node z such that, in the previous hour, there exists edge (x, z) and edge (y, z), but not edge (x, y). The bacteria keep evolving until no more edges can be formed. The following graph shows a type of bacteria which requires 2 hours to fully evolve: As it may take months if not years for the bacteria to evolve to its ultimate form, it is impossible for Jason to stay at the laboratory to observe the change of the bacteria throughout the entire process. Therefore, he wants you to calculate the time required for the bacteria to fully evolve, so that he can just get back to the laboratory on time. The first line contains an integer N. (2 N 5 105 ) The next N - 1 line each contains two integers u and v, which means there exists an edge between node u and v. (1 u, v N) The given graph is guaranteed to be a valid tree. an integer, the time (in hours) required for the bacteria to fully evolve. Example input 6 1 5 5 3 5 6 6 2 6 4 output 2

C Problem E Emptying the Baltic Problem ID: emptyingbaltic Time limit: 3 seconds Gunnar dislikes forces of nature and always comes up with innovative plans to decrease their influence over him. Even though his previous plan of a giant dome over Stockholm to protect from too much sunlight (as well as rain and snow) has not yet been realized, he is now focusing on preempting the possible effects climate change might have on the Baltic Sea, by the elegant solution of simply removing the Baltic from the equation. First, Gunnar wants to build a floodbank connecting Picture by Jeremy Halls on Flickr, cc by-sa Denmark and Norway to separate the Baltic from the Atlantic Ocean. The floodbank will also help protect Nordic countries from rising sea levels in the ocean. Next, Gunnar installs a device that can drain the Baltic from the seafloor. The device will drain as much water as needed to the Earth s core where it will disappear forever (because that is how physics works, at least as far as Gunnar is concerned). However, depending on the placement of the device, the entire Baltic might not be completely drained some pockets of water may remain. To simplify the problem, Gunnar is approximating the map of the Baltic using a 2-dimensional grid with 1 meter squares. For each square on the grid, he computes the average altitude. Squares with negative altitude are covered by water, squares with non-negative altitude are dry. Altitude is given in meters above the sea level, so the sea level has altitude of exactly 0. He disregards lakes and dry land below the sea level, as these would not change the estimate much anyway. Water from a square on the grid can flow to any of its 8 neighbours, even if the two squares only share a corner. The map is surrounded by dry land, so water never flows outside of the map. Water respects gravity, so it can only flow closer to the Earth s core either via the drainage device or to a neighbouring square with a lower water level. Gunnar is more of an idea person than a programmer, so he has asked for your help to evaluate how much water would be drained for a given placement of the device. The first line contains two integers h and w, 1 apple h, w apple 500, denoting the height and width of the map. Then follow h lines, each containing w integers. The first line represents the northernmost row of Gunnar s map. Each integer represents the altitude of a square on the map grid. The altitude is given in meters and it is at least 10 6 and at most 10 6. The last line contains two integers i and j, 1 apple i apple h, 1 apple j apple w, indicating that the draining device is placed in the cell corresponding to the j th column of the i th row. You may assume that position (i, j) has negative altitude (i.e., the draining device is not placed on land). one line with one integer the total volume of sea water drained, in cubic meters.

Sample 1 Sample 1 3 3-5 2-5 -1-2 -1 5 4-5 2 2 Sample 2 Sample 2 2 3-2 -3-4 -3-2 -3 2 1 10 16 Happy Birthday Jason Li!

D Problem F Fleecing the Raffle Problem ID: raffle Time limit: 2 seconds A tremendously exciting raffle is being held, with some tremendously exciting prizes being given out. All you have to do to have a chance of being a winner is to put a piece of paper with your name on it in the raffle box. The lucky winners of the p prizes are decided by drawing p names from the box. When a piece of paper with a name has been drawn it is not put back into the box each person can win at most one prize. Naturally, it is against the raffle rules to put your name in the box more than once. However, The Raffle (Raffling for the Goose) by William Sidney Mount, public domain it is only cheating if you are actually caught, and since not even the raffle organizers want to spend time checking all the names in the box, the only way you can get caught is if your name ends up being drawn for more than one of the prizes. This means that cheating and placing your name more than once can sometimes increase your chances of winning a prize. You know the number of names in the raffle box placed by other people, and the number of prizes that will be given out. By carefully choosing how many times to add your own name to the box, how large can you make your chances of winning a prize (i.e., the probability that your name is drawn exactly once)? The input consists of a single line containing two integers n and p (2 apple p apple n apple 10 6 ), where n is the number of names in the raffle box excluding yours, and p is the number of prizes that will be given away. a single line containing the maximum possible probability of winning a prize, accurate up to an absolute error of 10 6. Sample 1 Sample 1 3 2 0.6 Sample 2 Sample 2 23 5 0.45049857550

E Problem C Compass Card Sales Problem ID: compasscard Time limit: 6 seconds Katla has recently stopped playing the collectible card game Compass. As you might remember, Compass is a game where each card has a red, a green and a blue angle, each one between 0 and 359, as well as an ID. Since she has stopped playing, Katla has decided to sell all her cards. However, she wants to keep her deck as unique as possible while selling off the cards. Can you help her figure out the order in which she should sell the cards? To decide how unique a card is in the deck, she proceeds as follows. For each of the three colors she finds the closest other card in both directions, and then computes the angle between these two other cards. For instance if she has three cards with red angles 42, Picture via Wikimedia Commons, public domain 90 and 110, then the uniqueness values of their red angles are 340, 68, and 312, respectively. If two cards A and B have the same angle, B is considered the closest to A in both directions so that the uniqueness value of A (and B) for that color is 0. By summing the uniqueness values over the three colours, Katla finds how unique each card is. When selling a card, Katla sells the currently least unique card (smallest uniqueness value). If two cards have the same uniqueness value, she will sell the one with the higher ID first. After each card is sold, the uniqueness values of the remaining cards are updated before selling the next card. The first line of input contains an integer n, the number of cards (1 apple n apple 10 5 ). Then follows n lines. Each of these n lines contains 4 integers r, g, b, id (0 apple r, g, b < 360, 0 apple id < 2 31 ), giving the red, green and blue angles as well as the ID of a card. No two cards have the same ID. n lines, containing the IDs of the cards in the order they are to be sold, from first (least unique) to last (most unique). Sample 1 Sample 1 3 42 1 1 1 90 1 1 2 110 1 1 3 2 3 1 Sample 2 Sample 2 4 0 0 0 0 120 120 120 120 240 240 240 240 0 120 240 2017 2017 240 120 0

Problem H Highest Tower Problem ID: tower Time limit: 7 seconds Oni loved to build tall towers of blocks. Her parents were not as amused though. They were on the verge of going crazy over that annoying loud noise whenever a tower fell to the ground, not to mention having to pick up blocks from the floor all the time. Oni s mother one day had an idea. Instead of building the tower out of physical blocks, why couldn t Oni construct a picture of a tower using two-dimensional rectangles that she montaged on a board on the wall? Oni s mother cut out rectangles of various sizes and colors, drew a horizontal line representing the ground Photo by Matt Schilder on flickr, cc by-sa at the bottom of the board, and explained the rules of the game to Oni: every rectangle must be placed immediately above another rectangle or the ground line. For every rectangle you can choose which of its two orientations to use. I.e., if a rectangle has sides of length s and t, you can either have a side of length s horizontally or a side of length t horizontally. You may place exactly one rectangle immediately above another one if its horizontal side is strictly smaller than the horizontal side of the rectangle beneath. Exactly one rectangle must be placed on the ground line. Now try to build as tall a tower as possible! Oni s mother took extra care to make sure that it was indeed possible to use all rectangles in a tower in order not to discourage Oni. But of course Oni quickly lost interest anyway and returned to her physical blocks. After all, what is the point of building a tower if you cannot feel the suspense before the inevitable collapse? Her father on the other hand got interested by his wife s puzzle as he realized this is not a kids game. F The first line of input contains an integer n (1 apple n apple 250 000), the number of rectangles. Then follow n lines, each containing two integers s and t (1 apple s apple t apple 10 9 nm), the dimensions of a rectangle. You may safely assume that there is a way to build a tower using all n rectangles. a single line containing the height in nm of the tallest possible tower using all the rectangles while having the horizontal side lengths strictly decreasing from bottom to top. Sample 1 Sample 1 3 50000 160000 50000 100000 50000 100000 200000

Problem E Exponial Problem ID: exponial Time limit: 1 second Everybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing really big numbers known to humankind, for instance: Exponentiation: 42 2016 =42 42 {z... 42}. 2016 times Factorials: 2016! = 2016 2015... 2 1. In this problem we look at their lesser-known love-child the exponial, which is an operation defined for all positive integers n as exponial(n) =n (n 1)(n 2) 21. G Illustration of exponial(3) (not to scale), Picture by C.M. de Talleyrand-Périgord via Wikimedia Commons 1 For example, exponial(1) = 1 and exponial(5) = 5 432 6.206 10 183230 which is already pretty big. Note that exponentiation is right-associative: a bc = a (bc). Since the exponials are really big, they can be a bit unwieldy to work with. Therefore we would like you to write a program which computes exponial(n) modm (the remainder of exponial(n) when dividing by m). The input consists of two integers n (1 apple n apple 10 9 ) and m (1 apple m apple 10 9 ). a single integer, the value of exponial(n) modm. Sample 1 Sample 1 2 42 2 Sample 2 Sample 2 5 123456789 16317634 Sample 3 Sample 3 94 265 39