Codeforces Round 707 (Div. 1, based on Moscow Open Olympiad in Informatics)

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
1500 Codeforces Round 707 (Div. 1, based on Moscow Open Olympiad in Informatics) FINISHED False 9000 121726511 March 13, 2021, 9:05 a.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 355 ) F Cupboards Jumps PROGRAMMING dp 3500

B'In the house where Krosh used to live, he had n cupboards standing in a line, the i -th cupboard had the height of h_i . Krosh moved recently, but he wasn 't able to move the cupboards with him. Now he wants to buy n new cupboards so that they look as similar to old ones as possible. Krosh does not remember the exact heights of the cupboards, but for every three consecutive cupboards he remembers the height difference between the tallest and the shortest of them. In other words, if the cupboards ' heights were h_1, h_2, ldots, h_n , then Krosh remembers the values w_i = max(h_{i}, h_{i + 1}, h_{i + 2}) - min(h_{i}, h_{i + 1}, h_{i + 2}) for all 1 <= q i <= q n - 2 . Krosh wants to buy such n cupboards that all the values w_i remain the same. Help him determine the required cupboards ' heights, or determine that he remembers something incorrectly and there is no suitable sequence of heights. The first line contains two integers n and C ( 3 <= q n <= q 10^6 , 0 <= q C <= q 10^{12} ) -- the number of cupboards and the limit on possible w_i . The second line contains n - 2 integers w_1, w_2, ldots, w_{n - 2} ( 0 <= q w_i <= q C ) -- the values defined in the statement. If there is no suitable sequence of n cupboards, print "NO". Otherwise print "YES" in the first line, then in the second line print n integers h '_1, h '_2, ldots, h '_n ( 0 <= h '_i <= 10^{18} ) -- the heights of the cupboards to buy, from left to right. We can show that if there is a solution, there is also a solution satisfying the constraints on heights. If there are multiple answers, print any. Consider the first example: There are other possible solutions, for example, the following: 0, 1, 4, 9, 16, 25, 36 . '...

Tutorials

Codeforces Round #707 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
109889060 antontrygubO_o F March 13, 2021, 12:26 p.m. OK GNU C++17 TESTS 250 1887 208793600 3500
109926929 ecnerwala F March 13, 2021, 10:41 p.m. OK GNU C++17 (64) TESTS 250 483 53862400 3500
109926191 ecnerwala F March 13, 2021, 10:03 p.m. OK GNU C++17 (64) TESTS 250 498 53760000 3500
109893056 ecnerwala F March 13, 2021, 1:07 p.m. OK GNU C++17 (64) TESTS 250 530 53760000 3500
109892507 ecnerwala F March 13, 2021, 1 p.m. OK GNU C++17 (64) TESTS 250 545 53862400 3500
109906070 Ormlis F March 13, 2021, 3:27 p.m. OK GNU C++17 (64) TESTS 250 577 180736000 3500
109882523 tourist F March 13, 2021, 11:20 a.m. OK GNU C++17 (64) TESTS 250 795 96460800 3500

remove filters

Back to search problems