CF477E Dreamoon and Notepad
Description
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
Input Format
N/A
Output Format
N/A
Explanation/Hint
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.