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
The story was not finished as PMP thought. God offered him one more chance to reincarnate and come back to life. But before he can come back, God told him that PMP should ask n great men including prominent programmers about their life experiences. The men are standing on a straight line. They are numbered 1 through n from left to right. The coordinate of the i -th man is x i ( x i < x i + 1 , i < n ) . PMP should visit all these people one by one in arbitrary order. Each men should be visited exactly once . At the beginning of his tour, he starts at location of s -th man and asks him about his experiences. Each time PMP wants to change his location, he should give a ticket to an angel and the angel carries him to his destination. Angels take PMP from one location, fly to his destination and put him down there. Nobody else is visited in this movement. Moving from i -th man to j -th man, takes | x i - x j | time. PMP can get back to life as soon as he visits all men. There are two types of angels: Some angels are going to the right and they only accept right tickets. Others are going the left and they only accept left tickets. There are an unlimited number of angels of each type. PMP has l left tickets and n - 1 - l right tickets. PMP wants to get back to life as soon as possible to be able to compete in this year's final instead of the final he missed last year. He wants to know the quickest way to visit all the men exactly once. He also needs to know the exact sequence moves he should make. The first line of input contains three space-separated integers n , l , s ( 2 ≤ n ≤ 10 5 , 0 ≤ l < n , 1 ≤ s ≤ n ) — the number of people to visit, the number left tickets PMP got, and initial location of PMP. Next line contains n space-separated integers. The i -th integer in this line is x i ( 0 = x 1 < x 2 < ... < x n ≤ 10 9 ) — the location of i -th man. If PMP cannot visit all men with the tickets he got print -1 in the only line of output. Otherwise, in the first |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|
1803694 |
ACTheory |
E |
June 15, 2012, 2:48 a.m. |
OK |
FPC |
TESTS |
56 |
300 |
100966400 |
|
2800 |
|
41760568 |
Scut82 |
E |
Aug. 18, 2018, 2:21 p.m. |
OK |
GNU C++ |
TESTS |
56 |
62 |
2867200 |
|
2800 |
|
5419190 |
sy2006 |
E |
Dec. 13, 2013, 8:16 a.m. |
OK |
GNU C++ |
TESTS |
56 |
92 |
2048000 |
|
2800 |
|
5614503 |
PSDEV |
E |
Jan. 4, 2014, 7:58 a.m. |
OK |
GNU C++ |
TESTS |
56 |
92 |
2355200 |
|
2800 |
|
2305205 |
pwecar |
E |
Oct. 6, 2012, 7:56 a.m. |
OK |
GNU C++ |
TESTS |
56 |
109 |
3686400 |
|
2800 |
|
2419767 |
kokok |
E |
Oct. 24, 2012, 3:10 a.m. |
OK |
GNU C++ |
TESTS |
56 |
109 |
4915200 |
|
2800 |
|
2637364 |
hariprasath |
E |
Nov. 24, 2012, 11:58 a.m. |
OK |
GNU C++ |
TESTS |
56 |
109 |
9011200 |
|
2800 |
|
1679989 |
oimaster |
E |
May 10, 2012, 9:27 p.m. |
OK |
GNU C++ |
TESTS |
56 |
110 |
4608000 |
|
2800 |
|
1851100 |
ProCoder |
E |
July 3, 2012, 9:41 a.m. |
OK |
GNU C++ |
TESTS |
56 |
110 |
4710400 |
|
2800 |
|
1706060 |
guille |
E |
May 20, 2012, 11:09 a.m. |
OK |
GNU C++ |
TESTS |
56 |
110 |
6246400 |
|
2800 |
|
40991257 |
ReaLNero1 |
E |
July 31, 2018, 12:31 a.m. |
OK |
GNU C++ |
TESTS |
56 |
124 |
2252800 |
|
2800 |
|
57900864 |
lopare |
E |
July 28, 2019, 3:37 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
2252800 |
|
2800 |
|
57822478 |
py_ultron |
E |
July 27, 2019, 12:37 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
2252800 |
|
2800 |
|
14683563 |
SJas |
E |
Dec. 7, 2015, 7:54 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
2252800 |
|
2800 |
|
17298063 |
Los_Angelos_Laycurse |
E |
April 13, 2016, 6:12 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
2355200 |
|
2800 |
|
17298051 |
Los_Angelos_Laycurse |
E |
April 13, 2016, 6:11 a.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
2355200 |
|
2800 |
|
35843356 |
______u______ |
E |
March 2, 2018, 3:11 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
4403200 |
|
2800 |
|
35843336 |
______n______ |
E |
March 2, 2018, 3:10 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
4403200 |
|
2800 |
|
35843150 |
_____i_____ |
E |
March 2, 2018, 3:06 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
4403200 |
|
2800 |
|
35843144 |
_____k_____ |
E |
March 2, 2018, 3:06 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
4403200 |
|
2800 |
|
35838226 |
______k______ |
E |
March 2, 2018, 1:28 p.m. |
OK |
GNU C++11 |
TESTS |
56 |
124 |
4403200 |
|
2800 |
|
20995555 |
polytmus |
E |
Sept. 29, 2016, 2:46 p.m. |
OK |
GNU C++14 |
TESTS |
56 |
124 |
2867200 |
|
2800 |
|
23669985 |
Ali.Pi |
E |
Jan. 9, 2017, 7:37 p.m. |
OK |
GNU C++14 |
TESTS |
56 |
124 |
4300800 |
|
2800 |
|
33536139 |
Navick |
E |
Dec. 23, 2017, 11:47 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
186 |
7270400 |
|
2800 |
|
67271094 |
ElangBondol |
E |
Dec. 20, 2019, 8:20 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
218 |
6348800 |
|
2800 |
|
55990674 |
Scut82 |
E |
June 24, 2019, 7:28 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
248 |
4198400 |
|
2800 |
|
44575244 |
asd123wwww |
E |
Oct. 20, 2018, 6:48 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
248 |
7065600 |
|
2800 |
|
44575194 |
asd123wwww |
E |
Oct. 20, 2018, 6:46 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
248 |
7065600 |
|
2800 |
|
48204380 |
hychyc |
E |
Jan. 11, 2019, 7:49 a.m. |
OK |
GNU C++14 |
TESTS |
56 |
248 |
125235200 |
|
2800 |
|
35166050 |
LiChenKoh |
E |
Feb. 12, 2018, 12:57 a.m. |
OK |
GNU C++17 |
TESTS |
56 |
92 |
7168000 |
|
2800 |
|
44772739 |
ruo |
E |
Oct. 24, 2018, 1:02 p.m. |
OK |
GNU C++17 |
TESTS |
56 |
124 |
4812800 |
|
2800 |
|
17298066 |
Los_Angelos_Laycurse |
E |
April 13, 2016, 6:12 a.m. |
OK |
MS C++ |
TESTS |
56 |
124 |
2355200 |
|
2800 |
|
14437086 |
Los_Angelos_Laycurse |
E |
Nov. 24, 2015, 9:21 a.m. |
OK |
MS C++ |
TESTS |
56 |
124 |
2355200 |
|
2800 |
|
14437097 |
Los_Angelos_Laycurse |
E |
Nov. 24, 2015, 9:22 a.m. |
OK |
MS C++ |
TESTS |
56 |
156 |
2355200 |
|
2800 |
remove filters
Back to search problems