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
Nowadays, all gadgets are smart: smart phones, smart speakers, smart bulbs, and even smart elevators. The machines rise up. The headquarters of the human resistance is located in a skyscraper. However, the smart elevator tries to slow people down without revealing itself. There are (n) people in the skyscraper waiting for the elevator on different floors. Each person wants to get to another floor. Each person's destination floor is different from every other destination floor and from all starting floors. At the beginning, the elevator is located on the first floor. It moves one floor per unit of time. Whenever the doors open, it chooses the next floor and travels directly to it. The elevator can either go to the starting floor of the person who hasn't boarded the elevator yet and take them, or go to the destination floor of the person who is already in the elevator and disembark them. Note that the elevator doesn't stop on the intermediate floors even for the people who are already inside the elevator. The passenger boarding and disembarkation take negligible time. The elevator is big enough to accommodate all people at the same time. The goal of the elevator is to maximize the total time until all passengers have been delivered to their destination floors. Find the maximum total time starting from the first floor until the disembarkation of the last passenger. Elevator doesn't need to return to the first floor. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10\,000)). The description of the test cases follows. The first line of each test case contains a single integer (n) denoting the number of people ((1 \le n \le 10^5)). Each of the following (n) lines contains two integers (s_i) and (f_i) ((2 \le s_i, f_i \le 10^9)) denoting the starting and the destination floor of the person (i), respectively. All (2n) floors in the input are pairwise distinct. It |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
353925937 |
hansery |
E |
Dec. 18, 2025, 5:13 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
46 |
109 |
4198400 |
|
|
|
353830969 |
potato167 |
E |
Dec. 17, 2025, 10:57 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
46 |
125 |
0 |
|
|
|
353821790 |
Adam_GS ArturSmolenski |
E |
Dec. 17, 2025, 10:11 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
46 |
656 |
23142400 |
|
|
|
353824227 |
StarSilk |
E |
Dec. 17, 2025, 10:23 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
93 |
9625600 |
|
|
|
353849335 |
Noobish_Monk qwexd |
E |
Dec. 17, 2025, 12:44 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
109 |
102400 |
|
|
|
353852667 |
Rubikun |
E |
Dec. 17, 2025, 1:04 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
109 |
6758400 |
|
|
|
353841517 |
Rice_tawara459 noya2 shobonvip |
E |
Dec. 17, 2025, 11:57 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
125 |
6963200 |
|
|
|
353849517 |
keisuke6 hirayuu_cf |
E |
Dec. 17, 2025, 12:45 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
125 |
10752000 |
|
|
|
353836153 |
sunrise1024 fanglong thomaswmy |
E |
Dec. 17, 2025, 11:25 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
171 |
2560000 |
|
|
|
353840886 |
soahcrana |
E |
Dec. 17, 2025, 11:53 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
46 |
187 |
12083200 |
|
|
|
353921954 |
Djangle162857 |
E |
Dec. 18, 2025, 4:07 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
46 |
78 |
2150400 |
|
|
|
353823927 |
Kevin114514 jiangly jqdai0815 |
E |
Dec. 17, 2025, 10:21 a.m. |
OK |
C++23 (GCC 14-64, msys2) |
TESTS |
46 |
93 |
3584000 |
|
|
|
353832180 |
dyppp |
E |
Dec. 17, 2025, 11:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
46 |
953 |
40038400 |
|
|
remove filters
Back to search problems