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.
ContestId |
Name |
Phase |
Frozen |
Duration (Seconds) |
Relative Time |
Start Time |
|---|---|---|---|---|---|---|
| 477 | Codeforces Round 272 (Div. 1) | FINISHED | False | 7200 | 363283223 | Oct. 12, 2014, 2 p.m. |
Solved |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
|---|---|---|---|---|---|---|
| ( 159 ) | E | Dreamoon and Notepad | PROGRAMMING | data structures | 3100 |
Dreamoon has just created a document of hard problems using notepad.exe. The document consists of n lines of text, a i denotes the length of the i -th line. He now wants to know what is the fastest way to move the cursor around because the document is really long. Let ( r , c ) be a current cursor position, where r is row number and c is position of cursor in the row. We have 1 ≤ r ≤ n and 0 ≤ c ≤ a r . We can use following six operations in notepad.exe to move our cursor assuming the current cursor position is at ( r , c ) : up key: the new cursor position ( nr , nc ) = ( max ( r - 1, 1), min ( a nr , c )) down key: the new cursor position ( nr , nc ) = ( min ( r + 1, n ), min ( a nr , c )) left key: the new cursor position ( nr , nc ) = ( r , max (0, c - 1)) right key: the new cursor position ( nr , nc ) = ( r , min ( a nr , c + 1)) HOME key: the new cursor position ( nr , nc ) = ( r , 0) END key: the new cursor position ( nr , nc ) = ( r , a r ) You're given the document description ( n and sequence a i ) and q queries from Dreamoon. Each query asks what minimal number of key presses is needed to move the cursor from ( r 1 , c 1 ) to ( r 2 , c 2 ) . The first line contains an integer n (1 ≤ n ≤ 400, 000) — the number of lines of text. The second line contains n integers a 1 , a 2 , ..., a n (1 ≤ a i ≤ 10 8 ) . The third line contains an integer q (1 ≤ q ≤ 400, 000) . Each of the next q lines contains four integers r 1 , c 1 , r 2 , c 2 representing a query ( 1 ≤ r 1 , r 2 ≤ n , 0 ≤ c 1 ≤ a r 1 , 0 ≤ c 2 ≤ a r 2 ). For each query print the result of the query. In the first sample, the first query can be solved with keys: HOME, right. The second query can be solved with keys: down, down, down, END, down. The third query can be solved with keys: down, END, down. The fourth query can be solved with keys: END, down. |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 8210994 | Baklazan | E | Oct. 12, 2014, 6:53 p.m. | OK | GNU C++ | TESTS | 20 | 826 | 60211200 | 3100 | |
| 23338164 | Jin_Haonan | E | Dec. 26, 2016, 10:49 a.m. | OK | GNU C++ | TESTS | 20 | 858 | 32358400 | 3100 | |
| 9187440 | mosfjh | E | Dec. 18, 2014, 1:30 p.m. | OK | GNU C++ | TESTS | 20 | 858 | 163532800 | 3100 | |
| 8372983 | HSGSmaster | E | Oct. 24, 2014, 4:14 a.m. | OK | GNU C++ | TESTS | 20 | 872 | 60211200 | 3100 | |
| 8284183 | konstantanter | E | Oct. 17, 2014, 3:45 p.m. | OK | GNU C++ | TESTS | 20 | 997 | 60211200 | 3100 | |
| 15142657 | HappyNewYearMike | E | Dec. 31, 2015, 10:38 p.m. | OK | GNU C++ | TESTS | 20 | 1044 | 52428800 | 3100 | |
| 8746852 | jovid-55 | E | Nov. 18, 2014, 2:10 p.m. | OK | GNU C++ | TESTS | 20 | 1060 | 29900800 | 3100 | |
| 8708260 | zld3794955 | E | Nov. 16, 2014, 4:16 a.m. | OK | GNU C++ | TESTS | 20 | 1091 | 29900800 | 3100 | |
| 39021831 | vjudge4 | E | June 7, 2018, 12:52 p.m. | OK | GNU C++ | TESTS | 20 | 1106 | 49561600 | 3100 | |
| 8708270 | zld3794955 | E | Nov. 16, 2014, 4:20 a.m. | OK | GNU C++ | TESTS | 20 | 1107 | 29900800 | 3100 | |
| 8373364 | zhj | E | Oct. 24, 2014, 5:34 a.m. | OK | GNU C++0x | TESTS | 20 | 701 | 57548800 | 3100 | |
| 8211739 | gustav | E | Oct. 12, 2014, 8:07 p.m. | OK | GNU C++0x | TESTS | 20 | 1076 | 243712000 | 3100 | |
| 40987798 | ReaLNero1 | E | July 30, 2018, 9:29 p.m. | OK | GNU C++11 | TESTS | 20 | 795 | 51916800 | 3100 | |
| 17183809 | Los_Angelos_Laycurse | E | April 6, 2016, 10:02 a.m. | OK | GNU C++11 | TESTS | 20 | 810 | 54067200 | 3100 | |
| 52809693 | cuizhuyefei | E | April 16, 2019, 7:44 a.m. | OK | GNU C++11 | TESTS | 20 | 966 | 133120000 | 3100 | |
| 58702245 | shixiangyu | E | Aug. 13, 2019, 8:14 a.m. | OK | GNU C++11 | TESTS | 20 | 1013 | 59187200 | 3100 | |
| 11450585 | a00012025 | E | June 5, 2015, 5:20 p.m. | OK | GNU C++11 | TESTS | 20 | 1076 | 81203200 | 3100 | |
| 17183779 | Los_Angelos_Laycurse | E | April 6, 2016, 10 a.m. | OK | GNU C++11 | TESTS | 20 | 1138 | 54067200 | 3100 | |
| 17158935 | freebsdx | E | April 4, 2016, 2:12 p.m. | OK | GNU C++11 | TESTS | 20 | 1481 | 61337600 | 3100 | |
| 57888199 | lopare | E | July 28, 2019, 10:49 a.m. | OK | GNU C++11 | TESTS | 20 | 1606 | 117043200 | 3100 | |
| 52819783 | zx2003 | E | April 16, 2019, 11:25 a.m. | OK | GNU C++11 | TESTS | 20 | 1606 | 117043200 | 3100 | |
| 57818807 | py_ultron | E | July 26, 2019, 9:26 p.m. | OK | GNU C++11 | TESTS | 20 | 1606 | 117145600 | 3100 | |
| 38531821 | cyz666 | E | May 22, 2018, 10:39 a.m. | OK | GNU C++14 | TESTS | 20 | 1575 | 30720000 | 3100 | |
| 39062907 | yycdage | E | June 9, 2018, 7:33 a.m. | OK | GNU C++14 | TESTS | 20 | 2371 | 54272000 | 3100 | |
| 23524947 | Ali.Pi | E | Jan. 3, 2017, 9:51 p.m. | OK | GNU C++14 | TESTS | 20 | 2589 | 205516800 | 3100 | |
| 52809679 | CMXRYNP | E | April 16, 2019, 7:44 a.m. | OK | GNU C++17 | TESTS | 20 | 514 | 52224000 | 3100 | |
| 44489193 | tkj | E | Oct. 18, 2018, 1:48 p.m. | OK | GNU C++17 | TESTS | 20 | 826 | 51814400 | 3100 | |
| 52839876 | _Happy_New_Year_ | E | April 16, 2019, 3:03 p.m. | OK | GNU C++17 | TESTS | 20 | 1513 | 121856000 | 3100 | |
| 52837672 | _Happy_New_Year_ | E | April 16, 2019, 2:57 p.m. | OK | GNU C++17 | TESTS | 20 | 1653 | 121856000 | 3100 | |
| 17183826 | Los_Angelos_Laycurse | E | April 6, 2016, 10:03 a.m. | OK | MS C++ | TESTS | 20 | 935 | 54067200 | 3100 |
Back to search problems