Codeforces Beta Round 10

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
10 Codeforces Beta Round 10 FINISHED False 7200 504972880 April 15, 2010, 3:45 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 915 ) E Greedy Change PROGRAMMING constructive algorithms 2600

Billy investigates the question of applying greedy algorithm to different spheres of life. At the moment he is studying the application of greedy algorithm to the problem about change. There is an amount of n coins of different face values, and the coins of each value are not limited in number. The task is to collect the sum x with the minimum amount of coins. Greedy algorithm with each its step takes the coin of the highest face value, not exceeding x . Obviously, if among the coins' face values exists the face value 1, any sum x can be collected with the help of greedy algorithm. However, greedy algorithm does not always give the optimal representation of the sum, i.e. the representation with the minimum amount of coins. For example, if there are face values {1, 3, 4} and it is asked to collect the sum 6 , greedy algorithm will represent the sum as 4 + 1 + 1 , while the optimal representation is 3 + 3 , containing one coin less. By the given set of face values find out if there exist such a sum x that greedy algorithm will collect in a non-optimal way. If such a sum exists, find out the smallest of these sums. The first line contains an integer n ( 1 ≤ n ≤ 400 ) — the amount of the coins' face values. The second line contains n integers a i ( 1 ≤ a i ≤ 10 9 ), describing the face values. It is guaranteed that a 1 > a 2 > ... > a n and a n = 1 . If greedy algorithm collects any sum in an optimal way, output -1. Otherwise output the smallest sum that greedy algorithm collects in a non-optimal way.

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
44284 andrewzta E April 15, 2010, 4:45 p.m. OK Delphi TESTS 105 690 819200 2600
44963 LemonTree E April 15, 2010, 5:35 p.m. OK GNU C++ TESTS 105 200 1331200 2600
44689 Gassa E April 15, 2010, 5:16 p.m. OK GNU C++ TESTS 105 250 1331200 2600
44502 Rydberg E April 15, 2010, 5:02 p.m. OK GNU C++ TESTS 105 250 2048000 2600
44634 RoBa E April 15, 2010, 5:11 p.m. OK GNU C++ TESTS 105 530 1331200 2600
44973 dasko1 E April 15, 2010, 5:36 p.m. OK GNU C++ TESTS 105 750 2662400 2600
45211 aurinegro E April 15, 2010, 5:44 p.m. OK GNU C++ TESTS 105 890 1331200 2600
44474 gawry E April 15, 2010, 5 p.m. OK GNU C++ TESTS 105 890 1331200 2600
45158 ktuan E April 15, 2010, 5:43 p.m. OK GNU C++ TESTS 105 1470 1331200 2600
43889 Petr E April 15, 2010, 4:22 p.m. OK Java 6 TESTS 105 610 30720000 2600
44718 Philip_PV E April 15, 2010, 5:18 p.m. OK MS C++ TESTS 105 310 1331200 2600
44802 it4.kp E April 15, 2010, 5:25 p.m. OK MS C++ TESTS 105 920 1331200 2600

remove filters

Back to search problems