eolymp
bolt
Try our new interface for solving problems
Məsələlər

Stock Prices

Stock Prices

Buy low, sell high. That is what one should do to make profit in the stock market (we will ignore short selling here). Of course, no one can tell the price of a stock in the future, so it is difficult to know exactly when to buy and sell and how much profit one can make by repeatedly buying and selling a stock. But if you do have the history of price of a stock for the last n days, it is certainly possible to determine the maximum profit that could have been made. Instead, we are interested in finding the \textbf{k1} lowest prices and \textbf{k2} highest prices in the history. \InputFile The input consists of a number of cases. The first line of each case starts with positive integers \textbf{n}, \textbf{k1}, and \textbf{k2} on a line (n ≤ \textbf{1000000}, \textbf{k1 + k2} ≤ \textbf{n}, \textbf{k1}, \textbf{k2} ≤ \textbf{100}). The next line contains integers giving the prices of a stock in the last \textbf{n} days: the \textbf{i}-th integer (\textbf{1} ≤ \textbf{i} ≤ \textbf{n}) gives the stock price on day \textbf{i}. The stock prices are non-negative. The input is terminated by \textbf{n = k1 = k2 = 0}, and that case should not be processed. \OutputFile For each case, produce three lines of output. The first line contains the case number (starting from \textbf{1}) on one line. The second line specifies the days on which the \textbf{k1} lowest stock prices occur. The days are sorted in ascending order. The third line specifies the days on which the \textbf{k2} highest stock prices occur, and the days sorted in descending order. The entries in each list should be separated by a single space. If there are multiple correct lists for the lowest prices, choose the lexicographically smallest list. If there are multiple correct lists for the highest prices, choose the lexicographically largest list.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
10 3 2
1 2 3 4 5 6 7 8 9 10
10 3 2
10 9 8 7 6 5 4 3 2 1
0 0 0
Çıxış verilənləri #1
Case 1
1 2 3
10 9
Case 2
8 9 10
2 1
Mənbə 2011 Rocky Mountain Regional ACM Contest Information