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"You are given a circular array with n elements. The elements are numbered from some element with values from 1 to n in clockwise order. The i-th cell contains the value ai. The robot Simba is in cell s. Each moment of time the robot is in some of the n cells (at the begin he is in s). In one turn the robot can write out the number written in current cell or move to the adjacent cell in clockwise or counterclockwise direction. To write out the number from the cell Simba doesn't spend any time, but to move to adjacent cell Simba spends one unit of time. Simba wants to write the number from each cell one time, so the numbers will be written in a non decreasing order. Find the least number of time units to write out all numbers. The first line contains two integers n and s (1 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89s xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89 xe2 x89 xa4 xe2 x80 x892000) -- the number of cells in the circular array and the starting position of Simba. The second line contains n integers ai ( xe2 x80 x89- xe2 x80 x89109 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89ai xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89109) -- the number written in the i-th cell. The numbers are given for cells in order from 1 to n. Some of numbers ai can be equal. In the first line print the number t -- the least number of time units. Each of the next n lines should contain the direction of robot movement and the number of cells to move in that direction. After that movement the robot writes out the number from the cell in which it turns out. The direction and the number of cells should be printed in the form of +x in case of clockwise movement and -x in case of counterclockwise movement to x cells (0 xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89x xe2 x80 x89 xe2 x89 xa4 xe2 x80 x89n xe2 x80 x89- xe2 x80 x891). Note that the sum of absolute values of x should be equal to t."... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
15154927 |
Gassa |
F |
Jan. 2, 2016, 4:18 a.m. |
OK |
D |
TESTS |
27 |
15 |
4198400 |
|
2600 |
15079738 |
mukesh227 |
F |
Dec. 29, 2015, 4:59 a.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
0 |
|
2600 |
16027756 |
RNS3 |
F |
Feb. 15, 2016, 6:09 a.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
102400 |
|
2600 |
15158860 |
chihao.ict |
F |
Jan. 2, 2016, 1:30 p.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
102400 |
|
2600 |
15094344 |
chemthan |
F |
Dec. 30, 2015, 8:49 a.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
102400 |
|
2600 |
15032933 |
ivanilos |
F |
Dec. 26, 2015, 2:09 p.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
102400 |
|
2600 |
17967101 |
hehe0625 |
F |
May 17, 2016, 12:55 p.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
2355200 |
|
2600 |
15148019 |
guille |
F |
Jan. 1, 2016, 12:39 p.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
3993600 |
|
2600 |
15034032 |
130705009 |
F |
Dec. 26, 2015, 3:40 p.m. |
OK |
GNU C++ |
TESTS |
27 |
15 |
48742400 |
|
2600 |
15204218 |
HelenaBond |
F |
Jan. 6, 2016, 1:07 p.m. |
OK |
GNU C++ |
TESTS |
27 |
30 |
102400 |
|
2600 |
15034841 |
theprof |
F |
Dec. 26, 2015, 4:48 p.m. |
OK |
GNU C++ |
TESTS |
27 |
30 |
102400 |
|
2600 |
21783963 |
returnzoo |
F |
Oct. 26, 2016, 12:26 a.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
0 |
|
2600 |
15876335 |
89264270823 |
F |
Feb. 7, 2016, 1:12 p.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
0 |
|
2600 |
15136087 |
alkhwarizmi |
F |
Dec. 31, 2015, 11:41 a.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
0 |
|
2600 |
29844236 |
petil777 |
F |
Aug. 28, 2017, 11:36 a.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15186814 |
williamx |
F |
Jan. 5, 2016, 2:46 a.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15186240 |
LHiC |
F |
Jan. 4, 2016, 11:38 p.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15169896 |
krijgertje |
F |
Jan. 3, 2016, 3:16 p.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15130088 |
irkstepanov |
F |
Dec. 30, 2015, 10:50 p.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15086585 |
Meirambek |
F |
Dec. 29, 2015, 3:09 p.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
15080656 |
Rotile |
F |
Dec. 29, 2015, 7:04 a.m. |
OK |
GNU C++11 |
TESTS |
27 |
15 |
102400 |
|
2600 |
30032645 |
NiroBC |
F |
Sept. 3, 2017, 11:51 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
204800 |
|
2600 |
24718710 |
vjudge5 |
F |
Feb. 16, 2017, 1:25 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
2150400 |
|
2600 |
24707898 |
SssssssssssssbbbBBBB |
F |
Feb. 16, 2017, 1:53 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
2150400 |
|
2600 |
23466267 |
Ali.Pi |
F |
Dec. 31, 2016, 8:55 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
2252800 |
|
2600 |
25970746 |
Kmcode |
F |
March 31, 2017, 7:55 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
15 |
2355200 |
|
2600 |
69381860 |
pikmike |
F |
Jan. 22, 2020, 8:02 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
30 |
204800 |
|
2600 |
27179218 |
Lo_R_D |
F |
May 17, 2017, 12:27 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
30 |
307200 |
|
2600 |
26905937 |
dendi239 |
F |
May 6, 2017, 4:28 p.m. |
OK |
GNU C++14 |
TESTS |
27 |
30 |
512000 |
|
2600 |
66619342 |
KeyID |
F |
Dec. 11, 2019, 6:14 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
31 |
204800 |
|
2600 |
55588481 |
JU_RUO |
F |
June 15, 2019, 10:59 a.m. |
OK |
GNU C++14 |
TESTS |
27 |
31 |
204800 |
|
2600 |
69060854 |
ruo |
F |
Jan. 18, 2020, 4:26 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
30 |
204800 |
|
2600 |
63914967 |
hjk1030 |
F |
Oct. 31, 2019, 9:42 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
31 |
307200 |
|
2600 |
58668507 |
Slaaava |
F |
Aug. 12, 2019, 1:28 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
31 |
307200 |
|
2600 |
68622532 |
Ari |
F |
Jan. 11, 2020, 7:41 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
31 |
64614400 |
|
2600 |
46396100 |
verngutz |
F |
Nov. 30, 2018, 9:22 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
46 |
307200 |
|
2600 |
57468433 |
Abdelrhman_Akram |
F |
July 21, 2019, 4:46 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
61 |
204800 |
|
2600 |
55577131 |
vjudge1 |
F |
June 15, 2019, 2:39 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
62 |
129024000 |
|
2600 |
51475701 |
ei133333 |
F |
March 19, 2019, 9:16 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
77 |
64512000 |
|
2600 |
55937166 |
roll_no_1 |
F |
June 22, 2019, 2:33 p.m. |
OK |
GNU C++17 |
TESTS |
27 |
77 |
64716800 |
|
2600 |
69083643 |
fumiphys |
F |
Jan. 19, 2020, 7:27 a.m. |
OK |
GNU C++17 |
TESTS |
27 |
77 |
65536000 |
|
2600 |
19830771 |
pavel.rosputko |
F |
Aug. 12, 2016, 2:27 p.m. |
OK |
Haskell |
TESTS |
27 |
46 |
53248000 |
|
2600 |
19830759 |
pavel.rosputko |
F |
Aug. 12, 2016, 2:26 p.m. |
OK |
Haskell |
TESTS |
27 |
46 |
53248000 |
|
2600 |
19829981 |
pavel.rosputko |
F |
Aug. 12, 2016, 1:51 p.m. |
OK |
Haskell |
TESTS |
27 |
61 |
53248000 |
|
2600 |
19829789 |
pavel.rosputko |
F |
Aug. 12, 2016, 1:41 p.m. |
OK |
Haskell |
TESTS |
27 |
61 |
53248000 |
|
2600 |
19830107 |
pavel.rosputko |
F |
Aug. 12, 2016, 1:56 p.m. |
OK |
Haskell |
TESTS |
27 |
62 |
53248000 |
|
2600 |
19830076 |
pavel.rosputko |
F |
Aug. 12, 2016, 1:55 p.m. |
OK |
Haskell |
TESTS |
27 |
62 |
53248000 |
|
2600 |
19826493 |
pavel.rosputko |
F |
Aug. 12, 2016, 10:48 a.m. |
OK |
Haskell |
TESTS |
27 |
171 |
53248000 |
|
2600 |
15157084 |
uwi |
F |
Jan. 2, 2016, 10:11 a.m. |
OK |
Java 8 |
TESTS |
27 |
155 |
48435200 |
|
2600 |
15014820 |
Egor |
F |
Dec. 25, 2015, 4:02 p.m. |
OK |
Java 8 |
TESTS |
27 |
218 |
15360000 |
|
2600 |
64906057 |
Oom |
F |
Nov. 14, 2019, 9:57 p.m. |
OK |
Java 8 |
TESTS |
27 |
280 |
145408000 |
|
2600 |
15059021 |
og.kostya |
F |
Dec. 27, 2015, 4:47 p.m. |
OK |
MS C# |
TESTS |
27 |
265 |
5324800 |
|
2600 |
15030255 |
LLI_E_P_JI_O_K |
F |
Dec. 26, 2015, 10:42 a.m. |
OK |
MS C++ |
TESTS |
27 |
15 |
106291200 |
|
2600 |
15030236 |
LLI_E_P_JI_O_K |
F |
Dec. 26, 2015, 10:41 a.m. |
OK |
MS C++ |
TESTS |
27 |
15 |
106291200 |
|
2600 |
15061667 |
Perforator |
F |
Dec. 27, 2015, 8:27 p.m. |
OK |
MS C++ |
TESTS |
27 |
62 |
204800 |
|
2600 |
15161225 |
gugugu |
F |
Jan. 2, 2016, 5:48 p.m. |
OK |
PyPy 2 |
TESTS |
27 |
187 |
8089600 |
|
2600 |
15161790 |
aklecram |
F |
Jan. 2, 2016, 6:50 p.m. |
OK |
PyPy 2 |
TESTS |
27 |
265 |
9830400 |
|
2600 |
remove filters
Back to search problems