Problem A. Subway Tickets

Similar documents
Q i e v e 1 N,Q 5000

UW-Madison ACM ICPC Individual Contest

ACM Collegiate Programming Contest 2016 (Hong Kong)

Problem A. First Mission

Problem 2A Consider 101 natural numbers not exceeding 200. Prove that at least one of them is divisible by another one.

2013 Mid-Atlantic Regional Programming Contest

2009 ACM ICPC Southeast USA Regional Programming Contest. 7 November, 2009 PROBLEMS

UCF Local Contest August 31, 2013

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

Have your say: Auckland Council annual budget 2017 to 2018

2013 ACM ICPC Southeast USA Regional Programming Contest. 2 November, Division 1

Problem Set 7: Network Flows Fall 2018

The 2016 ACM-ICPC Asia China-Final Contest Problems

Kangaroo 2017 Student lukio

Printing: You may print to the printer at any time during the test.

Croatian Open Competition in Informatics, contest 6 April 12, 2008

Problem Set 7: Games Spring 2018

SAPO Finals 2017 Day 2 Cape Town, South Africa, 8 October standard output

Problem F "Advertisement"

Study Guide For use with pages

ProCo 2017 Advanced Division Round 1

1Solve linear. 2Solve linear. Then. Now. Why?

Algebra I Common Assessment # 4 Printable Version

2017 FHSPS Playoff February 25, 2017 Timber Creek High School

Problem A: Complex intersecting line segments

TASK KAMPANJA MJESEC SETNJA TRAMPOLIN. mjesec.pas mjesec.c mjesec.cpp. standard input (stdin) standard output (stdout)

Roberto Clemente Middle School

Date. Probability. Chapter

Northwestern European Regional Contest Eindhoven, November 24. Problems

The Ultimate Money Making System *** Earn a Living Stealing From the Casino ***

French-Australian Regional Informatics Olympiad 11th March, 2011

Lesson 16: The Computation of the Slope of a Non Vertical Line

Algorithms for Programming Contests SS16 - Week 13

MATH NUMBER SENSE 3 Performance Objective Task Analysis Benchmarks/Assessment Students: 1. Students understand place value of whole numbers.

State Math Contest 2018 Junior Exam

2017 Denison Spring Programming Contest Granville, Ohio 18 February, 2017

Olympiad Combinatorics. Pranav A. Sriram

1 Stove. Task. Input. Output. Constraints

Homework December Week 2 Red/Orange

COCI 2017/2018. Round #1, October 14th, Tasks. Task Time limit Memory limit Score. Cezar 1 s 64 MB 50. Tetris 1 s 64 MB 80

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

Pearson English Interactive 1 correlated to the Common European Framework (CEF)

36, 21, 27, 24, 54, 28,36, 43, 22, 29, 37, 40, 26, 25, 38, 23, 44, 30, 26, 39, 37, 40, 38, 36, 41, 45, 52, 42, 43, 42, 48, 50, 53

WPF PUZZLE GP 2017 ROUND 5A COMPETITION BOOKLET. Host Country: Czech Republic C D. Author: Jan Novotný

Gas Pipeline Construction

Students use absolute value to determine distance between integers on the coordinate plane in order to find side lengths of polygons.

UTD Programming Contest for High School Students April 1st, 2017

MidMichigan Olympiad Problems 5-6

Combinatorics: The Fine Art of Counting

Practice A. Solving Inequalities by Adding or Subtracting. Solve. Then match each solution set with its graph. 1. r 1 2 A. 2. m 3 6 B. 3. x 4 1 C.

Overview. Equipment. Setup. A Single Turn. Drawing a Domino

Advanced Excel. Table of Contents. Lesson 3 Solver

How I Work, and Use Scrum Personally

Overview Game Roles. Manufacturer. Hub Operator. Retailer. Mayor 2

2005 Galois Contest Wednesday, April 20, 2005

No Cost Online Marketing

Problems translated from Croatian by: Paula Gombar

Problem A Budget Travel

Problem D Daydreaming Stockbroker

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

WISCONSIN MIDDLE SCHOOL STATE MATHEMATICS MEET WISCONSIN MATHEMATICS COUNCIL March 2 6, 2015

HANOI STAR - APMOPS 2016 Training - PreTest1 First Round

Irish Collegiate Programming Contest Problem Set

JUNIOR STUDENT PROBLEMS

2015 Canadian Computing Olympiad Day 2, Problem 1 Cars on Ice

Problem A. Worst Locations

COCI 2008/2009 Contest #5, 7 th February 2009 TASK LJESNJAK JABUKA JAGODA LUBENICA TRESNJA KRUSKA

TASK FUNGHI ZMIJA TRAKTOR ZGODAN JABUKE DIVLJAK. standard input (stdio) standard output (stdout)

Attached is a packet containing items necessary for you to have mastered to do well in Algebra I.

TASK PATRIK POLICIJA SABOR

NRP Math Challenge Club

Rosa Parks Middle School. Summer Math Packet C2.0 Algebra Student Name: Teacher Name: Date:

Problem C The Stern-Brocot Number System Input: standard input Output: standard output

G6-M3-Lesson 7: Ordering Integers and Other Rational Numbers

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

Linear Functions Review

Problem A To and Fro (Problem appeared in the 2004/2005 Regional Competition in North America East Central.)

Combinatorics: The Fine Art of Counting

STUDENT'S BOOKLET. Shapes, Bees and Balloons. Meeting 20 Student s Booklet. Contents. April 27 UCI

For Reps The James Group, LLC. All Rights Reserved.v1.1

LESSON 2: THE INCLUSION-EXCLUSION PRINCIPLE

STATION #1: VARIABLES ON BOTH SIDES (BASIC) Copy and solve each equation. Show all work. OPTIONAL CHALLENGE QUESTIONS:

Math is Cool Masters

TASK OKUPLJANJE USPON RAZINE ABECEDA STEP VODA. uspon.pas uspon.c uspon.cpp. razine.pas razine.c razine.cpp

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

Problem F. Chessboard Coloring

FOLLOW UP AND FOLLOW THROUGH FOR RESULTS... Did you have a good time last night? What did you like best?

SHA532 Transcripts. Transcript: Forecasting Accuracy. Transcript: Meet The Booking Curve

2016 Canadian Computing Olympiad Day 2, Problem 1 O Canada

MAT3707. Tutorial letter 202/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/202/1/2017

State Math Contest (Junior)

The Modules. Module A - The Contracts. Symbols - What do they mean?

The 2017 British Informatics Olympiad

RTÉ Freedom of Information Disclosure Log of Completed Freedom of Information requests Q1 and Q2 (January - June 2017)

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

Noetic Learning Mathematics Contest

Problem A. Backward numbers. backw.in backw.out

STATION #1: VARIABLES ON BOTH SIDES (BASIC) Copy and solve each equation. Show all work. 2. z = 84 6z z = 12 OPTIONAL CHALLENGE QUESTIONS:

Problem A. Jumbled Compass

Mathematics Test. Go on to next page

Transcription:

Problem A. Subway Tickets Input file: Output file: Time limit: Memory limit: 2 seconds 256 megabytes In order to avoid traffic jams, the organizers of the International Olympiad of Metropolises have decided to use Subway for bringing participants from the hotel to the location of the contest. Now the organizers need to buy tickets. There are n participants of the Olympiad. The organizing committee has a travel card that can be used to pay for at most m rides. They can add rides to the card. There are two options to add rides to the card. It is possible to add 1 ride to the card at a cost of a rubles, or add 4 rides at a cost of b rubles. Any option can be used any number of times (possibly zero). Help the organizers to get at least n rides on the card, spending minimum amount of money. Input The first line of the input file contains integer m (1 m 10 15 ) the initial number of rides on the travel card. The second line contains one integer n (1 n 10 15 ) the number of participants of the Olympiad. The third line contains one integer a (1 a 1000) the cost of adding 1 ride to the card. The fourth line contains one integer b (1 b 1000) the cost of adding 4 rides to the card. Output Output one integer number the minimum cost of adding rides to the card, so that it will have at least n rides. Examples 1 3 1 10 2 4 9 10 3 8 9 10 Note In the first example it is optimal to add 1 ride twice. 2 10 19 In the second example it is better to add 4 rides to the travel card (only 2 of them will be used). In the third example it is optimal to add 1 ride once and add 4 rides once. Scoring Tests for this problem are divided into four groups. For each of the groups you earn points only if your solution passes all tests in this group and all tests in all previous groups. Page 1 of 9

Group Tests Points Additional constraints n, m Comments 0 1 3 0 Sample tests. 1 4 23 19 n, m 1000 2 24 43 27 n, m 1 000 000 3 44 63 54 Page 2 of 9

Problem B. Show business Input file: Output file: Time limit: Memory limit: 2 seconds 256 megabytes Evgeni is a rising star of pop music. At the beginning of the new season he wants to schedule his performances at different music festivals of his city. However, things are not that simple in the show business world. Evgeni knows that there will be n festivals this season. The i-th festival will take place from day l i to day r i, inclusive. Festivals do not overlap. Evgeni wants to maximize the number of festivals that he will take part in at least once. There is an additional limitation: according to Evgeni s contract, he is given some value d and has to choose some day x (x 0). Then he will be able to take part in festivals only on days x, x + d, x + 2d and so on. Note, that he may skip some of these days, i.e. he is not required to use all these days to take part in the festivals. Evgeni may pick any of the days x. He wants to maximize the number of festivals he will be able to participate at least once. If there are several optimal values x, he wants to pick the minimum of them. Input The first line of the input contains two integers n and d (1 n 100 000, 1 d 10 15 ) the number of festivals and the value of difference between two consecutive days that Evgeni is allowed to use for performance at festivals. Each of the next n lines defines the time range of some festival: the i-th of them contains two integers l i and r i (0 l i r i 10 15 ) the number of the first and the last day of the i-th festival. Output Print two integers: the maximum number of festivals Evgeni can take part in and the day his first performance should happen in order to achieve this number of participations. Days are numbered starting with zero. If there are many optimal days to start, print the minimum one. Examples 4 4 5 5 0 2 15 23 10 11 2 5 8 9 16 18 Note 3 1 2 3 In the first sample, if Evgeni starts on day 1 or day 2, he will be able to participate in three festivals. If he starts on day 1, he will be able to participate in festival 1 (day 5), festival 2 (day 1) and festival 3 (days 17 and 21). If he starts on day 2, he will be able to participate in festival 2 (day 2), festival 3 (days 18 and 22) and festival 4 (day 10). In the second sample Evgeni can take part in both festivals if he starts on day 3 or day 8. Page 3 of 9

Scoring Tests for this problem are divided into four groups. For each group you earn points only if your solution passes all tests of this group and all tests of all previous groups. Groups Tests Points Additional constraints n d l i, r i Comments 0 1 2 0 Sample tests. 1 3 25 21 n 1 000 d 1 000 l i, r i 1 000 000 2 26 43 30 n 1 000 d 1 000 3 44 62 49 Page 4 of 9

Problem C. All for O(1) shop Input file: Output file: Time limit: Memory limit: 1 second 512 megabytes There are two cashiers in the shop All for O(1). You have to simulate the behaviour of the customers by the log of the shop workflow. You are given the description of the following events in the chronological order: a new customer comes to the end of the line to the first cashier; b new customer comes to the end of the line to the second cashier; A first cashier serves one customer; B second cashier serves one customer; > first cashier closes; ] second cashier closes; < first cashier opens; [ second cashier opens. Any time some cashier closes, each person in the line to this cashier goes to another cashier in reverse order. Persons move one by one starting from the last. That means the person that was the last one in this line leaves first and goes to the other line, then goes person that was standing before the last person and so on. At the end, person that was first in the line that just closed becomes the last one in another line. When a cashier opens, people from the other line (again, in reverse order starting with the last one) leave and go to the new line if their position in it will be strictly smaller than their position in the line they are now. The list of events is correct if: Only closed cashiers may open; Only open cashiers may close; No customer comes to the line to the closed cashier; No cashier tries to serve the customer if it is closed; No cashier serves the customer if the corresponding line is empty; At any moment of time at least one cashier works. Customers are numbered starting with 1 in order they appear in the event log. At the beginning both cashiers are open and both lines are empty. Input The first line of the input contains an integer n (2 n 10 000 000) the number of events. The second line contains n characters that define events as described above. It s guaranteed that the list is correct and the input will contain at least one serve query. Page 5 of 9

Output Print one line: for each event of serving a customer print the last digit of his index without any blanks. Examples 15 aaaba>bbbb<bbaa 12 aaaaa><aabbb Note Explanation of the first sample: 143256 12543 No. Team Explanation Line ine 2 01 a Customer 1 comes to the line 1 1 02 a Customer 2 comes to the line 1 1, 2 03 a Customer 3 comes to the line 1 1, 2, 3 04 b Customer 4 comes to the line 2 1, 2, 3 4 05 A Customer 1 served in line 1 2, 3 4 06 > Cashier 1 closes 4, 3, 2 07 b Customer 5 comes to the line 2 4, 3, 2, 5 08 B Customer 4 served in line 2 3, 2, 5 09 B Customer 3 served in line 2 2, 5 10 b Customer 6 comes to the line 2 2, 5, 6 11 < Cashier 1 opens 6 2, 5 12 B Customer 2 served in line 2 6 5 13 B Customer 5 served in line 2 6 14 A Customer 6 served in line 1 15 a Customer 7 comes in to the line 1 7 Scoring Tests for this problem are divided into four groups. For each group you earn points only if your solution passes all tests of this group and all tests of all previous groups. Groups Tests Points Additional constraints n Comments 0 1 2 0 Sample tests. 1 3 28 26 n 1000 2 29 47 37 n 200 000 3 48 63 37 Page 6 of 9

Problem D. Advertisement Input file: Output file: Time limit: Memory limit: 3 seconds 128 megabytes Company BubbleGum plans to launch its new version of world famous operation system BubbleGum OS 10. The director of the company is the billionaire Bubble Gum. He wants all devices of the popular company Phony to have his new OS pre-installed. Last night Bubble Gum got an idea to place a huge ad in the city, such that the director of the Phony Fi Lin will see it on his way to work and back as many times as possible. Bubble Gum already knows the route of Fi Lin for tomorrow, so it s now time to find out the best position for the ad. If we look on the city from the height, its road system will look like an infinite uniform grid on the coordinate plane. All roads that go from north to south are numbered from west to east with consecutive integers, same as roads that go from west to east are numbered from south to north. Thus, there is exactly one pair of roads intersecting at any integer point (x, y). Fi Lin uses his personal driver, starts at point (0, 0) and moves to the north. While he is in the car he always looks rightward in respect to the direction of movement (for example, if the car is moving north, than Fi Lin is looking eastward, while if the car is moving west, than Fi Lin is looking northward). This means, he sees all the objects that are located on the ray of his sight. Moreover, when the car is making a turn, Fi Lin is able to see all the objects located in the corresponding angle. You are given n records of form a i, c i, where a i is the length of the corresponding segment of movement, c i is equal to L if the car turns to the left at the end of the segment and to R if it turns right. Records are numbered from 1 to n. It s guaranteed that at the end of the route the car gets back to the initial point and head to the north. As Fi Lin is a very busy man, the route might look strange, cross itself many times and even use the same road segment multiple times (possibly, in different directions). Ad is planned to be positioned at the center of some square of the grid. It will be big enough to be seen from any distance. Find the way to place an ad in such a way that Fi Lin will see it as many times as possible during his travel. Input The first line of the input contains an integer n (4 n 100 000) the number of segments of Fi Lin s car movement. Each of the next n lines contains a pair of integer a i (1 a i 2 10 9 ) and a character c i. It s guaranteed that the route matches the above description and that during his travel Fi Lin was always on the streets with absolute values strictly less than s. Note that the value of s is not given in the input and depends on the group number. Output Print two integers x and y, defining the square of the grid that should be used to possess the ad. Integer x should be equal to the number of road to the west of the ad, while y should be equal to the number of the road to the south. Both integers x and y should not exceed 10 9 by their absolute value. If there are several optimal answers, any of them is accepted. Page 7 of 9

Examples 4 1 0 6 1 R 2 L 2 L -1 1 Note In the first sample, Fi Lin will see the ad only once. In the second sample, Fi Lin will see the ad three times: while the car drives through segments 2 and 3, and while turning from segment 2 to segment 3. N W E S Scoring Tests for this problem are divided into six groups. For each group you earn points only if your solution passes all tests of this group and all tests of all previous groups. Page 8 of 9

Groups Tests Points Additional constraints n s Comments 0 1 2 0 Sample tests. 1 3 21 20 n 100 s 100 2 22 28 13 n 100 s 10 9 3 29 37 20 n 5 000 s 10 9 4 38 46 9 n 20 000 s 10 9 5 47 55 38 s 10 9 Page 9 of 9