## TLE '16 Contest 6 (Mock CCC) J4 - Ski Rentals

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are waiting in line to obtain ski rentals at Hack the North 2017. To get your ski, you must wait in one of three lines. Each line will have , , and skiers respectively. Additionally, each skier will have a wait time attached to them, where represents the number of seconds it takes for them to choose a rental.

At the end of every seconds, the last skier from the longest line (not longest wait time) will move to a line with a fewer amount of people if that line consists of fewer people than the one they are currently waiting in. If there are ties for the shortest or longest lines, nobody will move. The skiers who move will switch regardless of the new wait time in front of them.

How long will it take for all skiers to get their rentals?

#### Input Specification

The first line of input consists of three integers separated by spaces: , , and ().

The second line of input will have the wait times for the skiers in the line, in order from front to end of the line.

The third line of input will have the wait times for the skiers in the line, in order from front to end of the line.

The fourth line of input will have the wait times for the skiers in the line, in order from front to end of the line.

It is guaranteed that .

• For 4 of the 15 available marks, and .
• For an additional 4 of the 15 available marks, and .
• For an additional 4 of the 15 available marks, .

#### Output Specification

The output will contain a single integer, the number of seconds it takes for all skiers to get their rentals.

#### Sample Input 1

2 1 3
30 20
30
30 10 20

#### Sample Output 1

50

#### Sample Input 2

3 2 3
20 5 4
15 9
8 9 5

#### Sample Output 2

29

• commented on April 21, 2017, 6:36 p.m.

Batch 3 case 5 may not satisfy input specification.

• commented on April 22, 2017, 9:51 a.m.

Thank you, Jason!

• commented on Feb. 20, 2017, 10:31 p.m.

If there isn't a tie for the shortest or longest line, does the skier at the back of the longest line move to the back of the shortest line or the back of the second-shortest line, or the back any of those two lines?

• commented on Feb. 20, 2017, 11:10 p.m.

The skier will move to the back of the shortest line (the one with the least amount of people).