22128_Investmen

2022-5-16 18:21| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506132233800-Problem List-采集的数据-后羿采集器.html

Pro.ID

22128

Title

Investment

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22128

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 3000/1000 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Stock market analyzing is very important for investment. A good analysis may earn you a lot of money, or at least minimize your loss. Now you are asked to carry out such an important task. Please write a program to select out 2 most beneficial stocks.

    There are N kinds of stocks in the market and they are simply represented by integers from 1 to N. Each of the N stocks has an initial price which is changing frequently.

    Benefits are calculated as follows: if a stock has no previous price, then its benefit is 0, otherwise the benefit is its current price subtracts its previous price. For stocks with the same benefits, select the one with least id first.

    输入

    There are multiple test cases. The first line of each case is the number N ( 2 <= N <= 100000). Then followed by N lines and each line has an integer number Pi ( 1 <= Pi <= 10000 ) which specify the initial prices of the stocks from 1 to N. Then followed by k ( 0 <= k <= 100000 ) lines and each line may be either two integers-id and Pid which tells that the idth stock price changed to Pid, or an instruction "Report" (without quotes). After these k lines there will be a line containing only "EndOfCurrentCase" (without quotes), which indicate the end of current case. And after all cases there will be a line containing only "EndOfInput" (without quotes), which indicate the end of input.

    输出

    Description

    Stock market analyzing is very important for investment. A good analysis may earn you a lot of money, or at least minimize your loss. Now you are asked to carry out such an important task. Please write a program to select out 2 most beneficial stocks.

    There are N kinds of stocks in the market and they are simply represented by integers from 1 to N. Each of the N stocks has an initial price which is changing frequently.

    Benefits are calculated as follows: if a stock has no previous price, then its benefit is 0, otherwise the benefit is its current price subtracts its previous price. For stocks with the same benefits, select the one with least id first.

    Input
    There are multiple test cases. The first line of each case is the number N ( 2 <= N <= 100000). Then followed by N lines and each line has an integer number Pi ( 1 <= Pi <= 10000 ) which specify the initial prices of the stocks from 1 to N. Then followed by k ( 0 <= k <= 100000 ) lines and each line may be either two integers-id and Pid which tells that the idth stock price changed to Pid, or an instruction "Report" (without quotes). After these k lines there will be a line containing only "EndOfCurrentCase" (without quotes), which indicate the end of current case. And after all cases there will be a line containing only "EndOfInput" (without quotes), which indicate the end of input.
    Output
    For each case, output the case number (see the sample output) first, then followed by several lines, each line contains 2 integers (separated by a blank) specifying the top 2 stock ids corresponding to the "Report" instruction. No redundant spaces are needed.
    Sample Input
    4
    10
    20
    30
    40
    1
    100
    2 90
    3 80
    4 70
    Report
    Report
    2 60
    Report
    EndOfCurrentCase
    3
    1
    1
    1
    2 10
    3 20
    Report
    EndOfCurrentCase
    EndOfInput
    Sample Output
    Case 1:
    1 2
    1 2
    1 3
    Case 2:
    3 2
    Source

    样例输入

    4
    10
    20
    30
    40
    1
    100
    2 90
    3 80
    4 70
    Report
    Report
    2 60
    Report
    EndOfCurrentCase
    3
    1
    1
    1
    2 10
    3 20
    Report
    EndOfCurrentCase
    EndOfInput

    样例输出

    Case 1:
    1 2
    1 2
    1 3
    Case 2:
    3 2

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部