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'There are n cities numbered from 1 to n , and city i has beauty a_i . A salesman wants to start at city 1 , visit every city exactly once, and return to city 1 . For all i ne j , a flight from city i to city j costs max(c_i,a_j-a_i) dollars, where c_i is the price floor enforced by city i . Note that there is no absolute value. Find the minimum total cost for the salesman to complete his trip. The first line contains a single integer n ( 2 <= n <= 10^5 ) -- the number of cities. The i -th of the next n lines contains two integers a_i , c_i ( 0 <= a_i,c_i <= 10^9 ) -- the beauty and price floor of the i -th city. Output a single integer -- the minimum total cost. In the first test case, we can travel in order 1 to 3 to 2 to 1 . The total cost is 11 , and we cannot do better. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
111894118 |
hos.lyric |
C |
April 3, 2021, 3:09 p.m. |
OK |
D |
TESTS |
43 |
343 |
7577600 |
|
2200 |
111921143 |
Sanzenkai |
C |
April 3, 2021, 4:05 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
31 |
819200 |
|
2200 |
111925544 |
QwQcOrZ |
C |
April 3, 2021, 4:16 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
46 |
819200 |
|
2200 |
111965482 |
do_while_not_not_true |
C |
April 4, 2021, 4:42 a.m. |
OK |
GNU C++11 |
TESTS |
54 |
46 |
819200 |
|
2200 |
111959322 |
froggyzhang |
C |
April 4, 2021, 1:48 a.m. |
OK |
GNU C++11 |
TESTS |
54 |
46 |
819200 |
|
2200 |
111959271 |
froggyzhang |
C |
April 4, 2021, 1:47 a.m. |
OK |
GNU C++11 |
TESTS |
54 |
46 |
819200 |
|
2200 |
111918246 |
fishcathu. |
C |
April 3, 2021, 3:58 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
46 |
819200 |
|
2200 |
111958171 |
liuhengxi |
C |
April 4, 2021, 12:57 a.m. |
OK |
GNU C++11 |
TESTS |
54 |
46 |
1024000 |
|
2200 |
111959173 |
zhaohaikun |
C |
April 4, 2021, 1:45 a.m. |
OK |
GNU C++11 |
TESTS |
54 |
46 |
1228800 |
|
2200 |
111914363 |
Young.FQ |
C |
April 3, 2021, 3:48 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
46 |
1228800 |
|
2200 |
111912017 |
hzy9819 |
C |
April 3, 2021, 3:43 p.m. |
OK |
GNU C++11 |
TESTS |
43 |
46 |
1228800 |
|
2200 |
111902397 |
JaeminPark |
C |
April 3, 2021, 3:23 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
62 |
819200 |
|
2200 |
111946963 |
BSBandme |
C |
April 3, 2021, 6:59 p.m. |
OK |
GNU C++14 |
TESTS |
49 |
62 |
819200 |
|
2200 |
111963091 |
WonderMouse |
C |
April 4, 2021, 3:39 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
62 |
1228800 |
|
2200 |
111905834 |
peehs_moorhsum |
C |
April 3, 2021, 3:30 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
819200 |
|
2200 |
111960092 |
tzxydby |
C |
April 4, 2021, 2:13 a.m. |
OK |
GNU C++14 |
TESTS |
54 |
77 |
819200 |
|
2200 |
111930603 |
RedStar_13 |
C |
April 3, 2021, 4:31 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
1228800 |
|
2200 |
111894668 |
dlalswp25 |
C |
April 3, 2021, 3:09 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
1638400 |
|
2200 |
111922760 |
scli_weapon |
C |
April 3, 2021, 4:09 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
2457600 |
|
2200 |
111910870 |
SW2000 |
C |
April 3, 2021, 3:40 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
3174400 |
|
2200 |
111911182 |
Hongzy |
C |
April 3, 2021, 3:41 p.m. |
OK |
GNU C++14 |
TESTS |
43 |
77 |
6451200 |
|
2200 |
111889304 |
izone |
C |
April 3, 2021, 3:01 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
46 |
2969600 |
|
2200 |
111906301 |
YLWang |
C |
April 3, 2021, 3:31 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
46 |
8192000 |
|
2200 |
111930359 |
yukihana0416 |
C |
April 3, 2021, 4:30 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
46 |
18841600 |
|
2200 |
111954198 |
zucyo05 |
C |
April 3, 2021, 9:53 p.m. |
OK |
GNU C++17 |
TESTS |
52 |
46 |
99942400 |
|
2200 |
111961576 |
cppascalinux |
C |
April 4, 2021, 3 a.m. |
OK |
GNU C++17 |
TESTS |
54 |
62 |
819200 |
|
2200 |
111948948 |
couplefire |
C |
April 3, 2021, 7:36 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
77 |
819200 |
|
2200 |
111948897 |
X-Camp_Team_100 |
C |
April 3, 2021, 7:35 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
77 |
819200 |
|
2200 |
111943560 |
Parliament |
C |
April 3, 2021, 6:14 p.m. |
OK |
GNU C++17 |
TESTS |
49 |
77 |
819200 |
|
2200 |
111911682 |
Sugarii |
C |
April 3, 2021, 3:42 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
77 |
819200 |
|
2200 |
111885208 |
Miracle03 |
C |
April 3, 2021, 2:56 p.m. |
OK |
GNU C++17 |
TESTS |
43 |
77 |
2457600 |
|
2200 |
111899657 |
LayCurse |
C |
April 3, 2021, 3:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
31 |
99942400 |
|
2200 |
111958018 |
Mivik |
C |
April 4, 2021, 12:48 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
46 |
819200 |
|
2200 |
111939755 |
kessido |
C |
April 3, 2021, 5:41 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
46 |
819200 |
|
2200 |
111957149 |
BMYqwq |
C |
April 4, 2021, 12:02 a.m. |
OK |
GNU C++17 (64) |
TESTS |
54 |
46 |
4096000 |
|
2200 |
111950624 |
LayCurse |
C |
April 3, 2021, 8:17 p.m. |
OK |
GNU C++17 (64) |
TESTS |
50 |
46 |
99942400 |
|
2200 |
111909438 |
jacynkaa |
C |
April 3, 2021, 3:37 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
61 |
1638400 |
|
2200 |
111890717 |
m_99 |
C |
April 3, 2021, 3:03 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
61 |
1638400 |
|
2200 |
111926842 |
Vasyl_Protsiv |
C |
April 3, 2021, 4:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
61 |
2048000 |
|
2200 |
111949135 |
lookcook |
C |
April 3, 2021, 7:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
49 |
61 |
4198400 |
|
2200 |
111940022 |
TryMax |
C |
April 3, 2021, 5:43 p.m. |
OK |
GNU C++17 (64) |
TESTS |
43 |
61 |
24064000 |
|
2200 |
111937038 |
Hemose |
C |
April 3, 2021, 4:48 p.m. |
OK |
Java 11 |
TESTS |
43 |
280 |
0 |
|
2200 |
111927907 |
Apfeloxid |
C |
April 3, 2021, 4:23 p.m. |
OK |
Java 11 |
TESTS |
43 |
342 |
0 |
|
2200 |
111906832 |
cirno3153 |
C |
April 3, 2021, 3:32 p.m. |
OK |
Java 11 |
TESTS |
43 |
389 |
6246400 |
|
2200 |
111909888 |
uwi |
C |
April 3, 2021, 3:38 p.m. |
OK |
Java 11 |
TESTS |
43 |
389 |
6860800 |
|
2200 |
111956114 |
Agnimandur |
C |
April 3, 2021, 11:11 p.m. |
OK |
Java 8 |
TESTS |
54 |
218 |
0 |
|
2200 |
111952272 |
polyakoff |
C |
April 3, 2021, 8:57 p.m. |
OK |
Java 8 |
TESTS |
50 |
233 |
0 |
|
2200 |
111926909 |
ika |
C |
April 3, 2021, 4:20 p.m. |
OK |
Java 8 |
TESTS |
43 |
234 |
0 |
|
2200 |
111941742 |
TheSawan |
C |
April 3, 2021, 5:56 p.m. |
OK |
Java 8 |
TESTS |
43 |
249 |
0 |
|
2200 |
111919349 |
TheSawan |
C |
April 3, 2021, 4 p.m. |
OK |
Java 8 |
TESTS |
43 |
280 |
0 |
|
2200 |
111913275 |
dalt |
C |
April 3, 2021, 3:46 p.m. |
OK |
Java 8 |
TESTS |
43 |
280 |
0 |
|
2200 |
111921613 |
martins |
C |
April 3, 2021, 4:06 p.m. |
OK |
Java 8 |
TESTS |
43 |
312 |
0 |
|
2200 |
111939407 |
YahiaSherif |
C |
April 3, 2021, 5:39 p.m. |
OK |
Java 8 |
TESTS |
43 |
358 |
4505600 |
|
2200 |
111919571 |
hu_tao |
C |
April 3, 2021, 4:01 p.m. |
OK |
Java 8 |
TESTS |
43 |
389 |
10956800 |
|
2200 |
111933251 |
2020akadaver |
C |
April 3, 2021, 4:39 p.m. |
OK |
Java 8 |
TESTS |
43 |
529 |
0 |
|
2200 |
111924193 |
alexey.enkov |
C |
April 3, 2021, 4:13 p.m. |
OK |
Kotlin |
TESTS |
43 |
342 |
1843200 |
|
2200 |
111935075 |
arvindf232 |
C |
April 3, 2021, 4:44 p.m. |
OK |
Kotlin |
TESTS |
43 |
451 |
19148800 |
|
2200 |
111950789 |
Sergey.Bankevich |
C |
April 3, 2021, 8:20 p.m. |
OK |
Kotlin |
TESTS |
50 |
483 |
2457600 |
|
2200 |
111950843 |
Sergey.Bankevich |
C |
April 3, 2021, 8:21 p.m. |
OK |
Kotlin |
TESTS |
50 |
561 |
2457600 |
|
2200 |
111924650 |
Tlatoani |
C |
April 3, 2021, 4:14 p.m. |
OK |
Kotlin |
TESTS |
43 |
576 |
18124800 |
|
2200 |
111940000 |
vpike |
C |
April 3, 2021, 5:42 p.m. |
OK |
MS C++ 2017 |
TESTS |
43 |
217 |
4812800 |
|
2200 |
111919575 |
mban259 |
C |
April 3, 2021, 4:01 p.m. |
OK |
.NET Core C# |
TESTS |
43 |
202 |
10035200 |
|
2200 |
111915809 |
.I. |
C |
April 3, 2021, 3:52 p.m. |
OK |
.NET Core C# |
TESTS |
43 |
217 |
10035200 |
|
2200 |
111923439 |
Yupiteru |
C |
April 3, 2021, 4:11 p.m. |
OK |
.NET Core C# |
TESTS |
43 |
312 |
21196800 |
|
2200 |
111901184 |
keymoon |
C |
April 3, 2021, 3:21 p.m. |
OK |
.NET Core C# |
TESTS |
43 |
342 |
17612800 |
|
2200 |
111949231 |
fairy_lettuce |
C |
April 3, 2021, 7:42 p.m. |
OK |
.NET Core C# |
TESTS |
49 |
451 |
22528000 |
|
2200 |
111939447 |
at_f |
C |
April 3, 2021, 5:39 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
358 |
18534400 |
|
2200 |
111901339 |
conqueror_of_tourist |
C |
April 3, 2021, 3:21 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
421 |
10752000 |
|
2200 |
111915914 |
FlakeLCR |
C |
April 3, 2021, 3:52 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
452 |
12697600 |
|
2200 |
111960527 |
tamato |
C |
April 4, 2021, 2:30 a.m. |
OK |
PyPy 3 |
TESTS |
54 |
482 |
14438400 |
|
2200 |
111919508 |
kclee2172 |
C |
April 3, 2021, 4:01 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
483 |
12390400 |
|
2200 |
111939537 |
jimm89 |
C |
April 3, 2021, 5:40 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
514 |
13926400 |
|
2200 |
111924540 |
i8nd5t |
C |
April 3, 2021, 4:14 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
561 |
27443200 |
|
2200 |
111940411 |
Kira_1234 |
C |
April 3, 2021, 5:45 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
576 |
10240000 |
|
2200 |
111896121 |
qwertz73355a |
C |
April 3, 2021, 3:12 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
608 |
11059200 |
|
2200 |
111930004 |
SPD_9X2 |
C |
April 3, 2021, 4:29 p.m. |
OK |
PyPy 3 |
TESTS |
43 |
686 |
11571200 |
|
2200 |
111923035 |
nwi |
C |
April 3, 2021, 4:10 p.m. |
OK |
Python 2 |
TESTS |
43 |
1091 |
15462400 |
|
2200 |
111942937 |
r57shell |
C |
April 3, 2021, 6:08 p.m. |
OK |
Python 3 |
TESTS |
49 |
343 |
7680000 |
|
2200 |
111931953 |
kwangg |
C |
April 3, 2021, 4:35 p.m. |
OK |
Python 3 |
TESTS |
43 |
608 |
7680000 |
|
2200 |
111934746 |
Russell_Emerine |
C |
April 3, 2021, 4:43 p.m. |
OK |
Rust |
TESTS |
43 |
93 |
1638400 |
|
2200 |
111896144 |
sansen |
C |
April 3, 2021, 3:12 p.m. |
OK |
Rust |
TESTS |
43 |
93 |
4608000 |
|
2200 |
111932833 |
cottoncotton |
C |
April 3, 2021, 4:37 p.m. |
OK |
Rust |
TESTS |
43 |
109 |
5120000 |
|
2200 |
111909338 |
toomer |
C |
April 3, 2021, 3:37 p.m. |
OK |
Rust |
TESTS |
43 |
109 |
8908800 |
|
2200 |
remove filters
Back to search problems