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 |
---|---|---|---|---|---|---|
1506 | Codeforces Round 710 (Div. 3) | FINISHED | False | 7200 | 115140299 | March 25, 2021, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 3298 ) | F | Triangular Paths | PROGRAMMING | constructive algorithms greedy math shortest paths sortings |
B"Consider an infinite triangle made up of layers. Let's number the layers, starting from one, from the top of the triangle (from top to bottom). The k -th layer of the triangle contains k points, numbered from left to right. Each point of an infinite triangle is described by a pair of numbers (r, c) ( 1 <= c <= r ), where r is the number of the layer, and c is the number of the point in the layer. From each point (r, c) there are two directed edges to the points (r+1, c) and (r+1, c+1) , but only one of the edges is activated. If r + c is even, then the edge to the point (r+1, c) is activated, otherwise the edge to the point (r+1, c+1) is activated. Look at the picture for a better understanding. From the point (r_1, c_1) it is possible to reach the point (r_2, c_2) , if there is a path between them only from activated edges. For example, in the picture above, there is a path from (1, 1) to (3, 2) , but there is no path from (2, 1) to (1, 1) . Initially, you are at the point (1, 1) . For each turn, you can: You are given a sequence of n points of an infinite triangle (r_1, c_1), (r_2, c_2), ldots, (r_n, c_n) . Find the minimum cost path from (1, 1) , passing through all n points in arbitrary order. The first line contains one integer t ( 1 <= t <= 10^4 ) is the number of test cases. Then t test cases follow. Each test case begins with a line containing one integer n ( 1 <= n <= 2 cdot 10^5 ) is the number of points to visit. The second line contains n numbers r_1, r_2, ldots, r_n ( 1 <= r_i <= 10^9 ), where r_i is the number of the layer in which i -th point is located. The third line contains n numbers c_1, c_2, ldots, c_n ( 1 <= c_i <= r_i ), where c_i is the number of the i -th point in the r_i layer. It is guaranteed that all $$"... |
Editorial |
No solutions yet.