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.
Problems
B'You live on a number line. You are initially (at time moment t = 0 ) located at point x = 0 . There are n events of the following type: at time t_i a small cake appears at coordinate x_i . To collect this cake, you have to be at this coordinate at this point, otherwise the cake spoils immediately. No two cakes appear at the same time and no two cakes appear at the same coordinate. You can move with the speed of 1 length unit per one time unit. Also, at any moment you can create a clone of yourself at the same point where you are located. The clone can 't move, but it will collect the cakes appearing at this position for you. The clone disappears when you create another clone. If the new clone is created at time moment t , the old clone can collect the cakes that appear before or at the time moment t , and the new clone can collect the cakes that appear at or after time moment t . Can you collect all the cakes (by yourself or with the help of clones)? The first line contains a single integer n ( 1 <= n <= 5000 ) -- the number of cakes. Each of the next n lines contains two integers t_i and x_i ( 1 <= t_i <= 10^9 , -10^9 <= x_i <= 10^9 ) -- the time and coordinate of a cake 's appearance. All times are distinct and are given in increasing order, all the coordinates are distinct. Print "YES" if you can collect all cakes, otherwise print "NO". In the first example you should start moving towards 5 right away, leaving a clone at position 1 at time moment 1 , and collecting the cake at position 2 at time moment 2 . At time moment 5 you are at the position 5 and collect a cake there, your clone collects the last cake at time moment 6 . In the second example you have to leave a clone at position 0 and start moving towards position 5 . At time moment 1 the clone collects a cake. At time moment 2 you should '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
99941154 |
xiahongyu |
F |
Nov. 29, 2020, 11:41 p.m. |
OK |
GNU C++11 |
TESTS |
49 |
171 |
25190400 |
|
|
99947458 |
train2004 |
F |
Nov. 30, 2020, 2:07 a.m. |
OK |
GNU C++11 |
TESTS |
49 |
296 |
25292800 |
|
|
99926977 |
peti1234 |
F |
Nov. 29, 2020, 4:57 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
108 |
102400 |
|
|
99935653 |
IdoItMyWay |
F |
Nov. 29, 2020, 7:56 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
140 |
3891200 |
|
|
99935680 |
IdoItMyWay |
F |
Nov. 29, 2020, 7:57 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
156 |
3891200 |
|
|
99920651 |
vjudge2 |
F |
Nov. 29, 2020, 3:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
140 |
25804800 |
|
|
remove filters
Back to search problems