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
You work in a big office. It is a 9 floor building with an elevator that can accommodate up to 4 people. It is your responsibility to manage this elevator. Today you are late, so there are queues on some floors already. For each person you know the floor where he currently is and the floor he wants to reach. Also, you know the order in which people came to the elevator. According to the company's rules, if an employee comes to the elevator earlier than another one, he has to enter the elevator earlier too (even if these employees stay on different floors). Note that the employees are allowed to leave the elevator in arbitrary order. The elevator has two commands: Go up or down one floor. The movement takes 1 second. Open the doors on the current floor. During this operation all the employees who have reached their destination get out of the elevator. Then all the employees on the floor get in the elevator in the order they are queued up while it doesn't contradict the company's rules and there is enough space in the elevator. Each employee spends 1 second to get inside and outside the elevator. Initially the elevator is empty and is located on the floor 1 . You are interested what is the minimum possible time you need to spend to deliver all the employees to their destination. It is not necessary to return the elevator to the floor 1 . The first line contains an integer n ( 1 ≤ n ≤ 2000 ) — the number of employees. The i -th of the next n lines contains two integers a i and b i ( 1 ≤ a i , b i ≤ 9 , a i ≠ b i ) — the floor on which an employee initially is, and the floor he wants to reach. The employees are given in the order they came to the elevator. Print a single integer — the minimal possible time in seconds. t = 2 t = 3 t = 5 t = 6 t = 7 t = 9 t = 10 |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
38308865 |
fluffyowl |
C |
May 16, 2018, 5:06 a.m. |
OK |
D |
TESTS |
47 |
109 |
100147200 |
|
2500 |
|
38290956 |
Gassa |
C |
May 15, 2018, 4:10 p.m. |
OK |
D |
TESTS |
47 |
1653 |
77004800 |
|
2500 |
|
38432784 |
tomekkulczynski |
C |
May 19, 2018, 1:49 p.m. |
OK |
GNU C++ |
TESTS |
47 |
31 |
202752000 |
|
2500 |
|
38326742 |
KatherineLOVER |
C |
May 16, 2018, 4:16 p.m. |
OK |
GNU C++ |
TESTS |
47 |
46 |
15052800 |
|
2500 |
|
39134665 |
_ShadowSong |
C |
June 11, 2018, 2:14 a.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
102400 |
|
2500 |
|
38413598 |
thx |
C |
May 19, 2018, 1:04 a.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
204800 |
|
2500 |
|
38303179 |
Scut82 |
C |
May 15, 2018, 9:21 p.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
9420800 |
|
2500 |
|
41296863 |
vjudge5 |
C |
Aug. 7, 2018, 7:42 a.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
13414400 |
|
2500 |
|
41296856 |
vjudge2 |
C |
Aug. 7, 2018, 7:42 a.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
13414400 |
|
2500 |
|
41555445 |
mayaohua2003 |
C |
Aug. 13, 2018, 11 a.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
72601600 |
|
2500 |
|
38290524 |
Nicolas16 |
C |
May 15, 2018, 4:07 p.m. |
OK |
GNU C++ |
TESTS |
47 |
62 |
119091200 |
|
2500 |
|
38290580 |
nwi |
C |
May 15, 2018, 4:07 p.m. |
OK |
GNU C++ |
TESTS |
47 |
93 |
61235200 |
|
2500 |
|
38702017 |
skaahy |
C |
May 28, 2018, 6:25 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
1228800 |
|
2500 |
|
38296364 |
receed |
C |
May 15, 2018, 4:41 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
3584000 |
|
2500 |
|
38306782 |
Eriri_Sawamura |
C |
May 16, 2018, 2:53 a.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
11673600 |
|
2500 |
|
38304454 |
kzoacn |
C |
May 15, 2018, 11:36 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
11776000 |
|
2500 |
|
38311828 |
Jiburiru |
C |
May 16, 2018, 7 a.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
12083200 |
|
2500 |
|
38354552 |
Z0RR0 |
C |
May 17, 2018, 3:55 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
31 |
77209600 |
|
2500 |
|
38407489 |
Paul-Andre |
C |
May 18, 2018, 5:36 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
46 |
0 |
|
2500 |
|
38290930 |
Blue233333 |
C |
May 15, 2018, 4:10 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
46 |
3481600 |
|
2500 |
|
38656230 |
osayes |
C |
May 27, 2018, 1:29 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
46 |
8089600 |
|
2500 |
|
42673490 |
Samaritan123 |
C |
Sept. 8, 2018, 12:20 p.m. |
OK |
GNU C++11 |
TESTS |
47 |
46 |
8499200 |
|
2500 |
|
40932091 |
ReaLNero1 |
C |
July 30, 2018, 1:34 a.m. |
OK |
GNU C++14 |
TESTS |
47 |
31 |
7987200 |
|
2500 |
|
38288838 |
WA_TLE |
C |
May 15, 2018, 3:57 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
31 |
11366400 |
|
2500 |
|
38290908 |
natsugiri |
C |
May 15, 2018, 4:09 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
31 |
11468800 |
|
2500 |
|
38306033 |
dreamoon_love_AA |
C |
May 16, 2018, 2:04 a.m. |
OK |
GNU C++14 |
TESTS |
47 |
31 |
16384000 |
|
2500 |
|
38416671 |
shdut |
C |
May 19, 2018, 4:31 a.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
409600 |
|
2500 |
|
38294080 |
ultmaster |
C |
May 15, 2018, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
3584000 |
|
2500 |
|
38318299 |
kblack |
C |
May 16, 2018, 11:12 a.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
3891200 |
|
2500 |
|
38289768 |
fanache99 |
C |
May 15, 2018, 4:03 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
5017600 |
|
2500 |
|
38304024 |
espr1t |
C |
May 15, 2018, 10:43 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
69939200 |
|
2500 |
|
38292833 |
Taube |
C |
May 15, 2018, 4:21 p.m. |
OK |
GNU C++14 |
TESTS |
47 |
46 |
87756800 |
|
2500 |
|
38349491 |
hicodeworld |
C |
May 17, 2018, 12:58 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
31 |
8294400 |
|
2500 |
|
38393049 |
kczno1 |
C |
May 18, 2018, 7:32 a.m. |
OK |
GNU C++17 |
TESTS |
47 |
31 |
8396800 |
|
2500 |
|
47264214 |
luogu_bot2 |
C |
Dec. 19, 2018, 1:37 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
31 |
14540800 |
|
2500 |
|
38416038 |
Timsei |
C |
May 19, 2018, 3:55 a.m. |
OK |
GNU C++17 |
TESTS |
47 |
46 |
3686400 |
|
2500 |
|
47264091 |
374272 |
C |
Dec. 19, 2018, 1:35 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
46 |
14540800 |
|
2500 |
|
38298804 |
Shik |
C |
May 15, 2018, 6:26 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
46 |
54988800 |
|
2500 |
|
38698341 |
rzwei |
C |
May 28, 2018, 3:32 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
46 |
200908800 |
|
2500 |
|
48882763 |
chinmay0906 |
C |
Jan. 24, 2019, 11:04 a.m. |
OK |
GNU C++17 |
TESTS |
47 |
62 |
26726400 |
|
2500 |
|
38284560 |
izban |
C |
May 15, 2018, 3:32 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
77 |
57856000 |
|
2500 |
|
43586798 |
yujinwunz |
C |
Sept. 29, 2018, 8:38 p.m. |
OK |
GNU C++17 |
TESTS |
47 |
77 |
80691200 |
|
2500 |
|
38389923 |
Suzukaze |
C |
May 18, 2018, 5:30 a.m. |
OK |
Java 8 |
TESTS |
47 |
171 |
0 |
|
2500 |
|
38295678 |
xiaowuc1 |
C |
May 15, 2018, 4:37 p.m. |
OK |
Java 8 |
TESTS |
47 |
280 |
27033600 |
|
2500 |
|
39059747 |
Tom--CCS |
C |
June 9, 2018, 4:35 a.m. |
OK |
Java 8 |
TESTS |
47 |
296 |
23961600 |
|
2500 |
|
38281120 |
Egor |
C |
May 15, 2018, 3:16 p.m. |
OK |
Java 8 |
TESTS |
47 |
1247 |
268390400 |
|
2500 |
|
38966324 |
7dan |
C |
June 5, 2018, 10:56 a.m. |
OK |
Java 8 |
TESTS |
47 |
1481 |
91955200 |
|
2500 |
|
38301537 |
wflms20110333 |
C |
May 15, 2018, 7:44 p.m. |
OK |
Java 8 |
TESTS |
47 |
2464 |
21913600 |
|
2500 |
|
38295149 |
SaveVMK |
C |
May 15, 2018, 4:34 p.m. |
OK |
Java 8 |
TESTS |
47 |
2526 |
158003200 |
|
2500 |
|
38293463 |
ymatsux |
C |
May 15, 2018, 4:25 p.m. |
OK |
Kotlin |
TESTS |
47 |
1700 |
100352000 |
|
2500 |
|
38699222 |
antofik |
C |
May 28, 2018, 4:10 p.m. |
OK |
Mono C# |
TESTS |
47 |
62 |
6758400 |
|
2500 |
|
45501761 |
LoneFox |
C |
Nov. 10, 2018, 8:03 a.m. |
OK |
MS C++ |
TESTS |
47 |
61 |
4812800 |
|
2500 |
|
38289112 |
wa1tz719 |
C |
May 15, 2018, 3:59 p.m. |
OK |
MS C++ |
TESTS |
47 |
77 |
68300800 |
|
2500 |
|
38307599 |
Borisp |
C |
May 16, 2018, 3:43 a.m. |
OK |
MS C++ |
TESTS |
47 |
124 |
79155200 |
|
2500 |
|
38302840 |
Borisp |
C |
May 15, 2018, 8:55 p.m. |
OK |
MS C++ |
TESTS |
47 |
124 |
79155200 |
|
2500 |
|
39128022 |
belkka |
C |
June 10, 2018, 5:31 p.m. |
OK |
PyPy 3 |
TESTS |
47 |
685 |
9216000 |
|
2500 |
|
39128201 |
belkka |
C |
June 10, 2018, 5:39 p.m. |
OK |
Python 3 |
TESTS |
47 |
187 |
716800 |
|
2500 |
remove filters
Back to search problems