Logo
(追記) (追記ここまで)

21393번 - Stock 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB3811642.857%

문제

After years of hard work Optiver has developed a mathematical model that allows them to predict wether or not a company will be succesful. This obviously gives them a great advantage on the stock market.

In the past, Optiver made a deal with a big company, which forces them to buy shares of the company according to a fixed schedule. Unfortunately, Optiver’s model has determined that the company will go bankrupt after exactly n days, after which their shares will become worthless.

Still, Optiver holds a large number of sell options that allows them to sell some of the shares before the company goes bankrupt. However, there is a limit on the number of shares Optiver can sell every day, and price Optiver receives for a share may vary from day to day. Therefore, it is not immediately clear when Optiver should sell their shares to maximize their profit, so they asked you to write a program to calculcate this.

입력

On the first line an integer t (1 ≤ t ≤ 100): the number of test cases. Then for each test case:

  • One line with an integer n (1 ≤ n ≤ 100 000): the number of days before the company goes bankrupt.
  • n lines with three integers xi (0 ≤ xi ≤ 100), pi (0 ≤ pi ≤ 100) and mi (0 ≤ mi ≤ 10 000 000): the number of shares Optiver receives on day i, the (selling) price per share on day i, and the maximum number of shares Optiver can sell on day i, respectively.

출력

For each test case:

  • One line with the maximum profit Optiver can achieve.

제한

예제 입력 1

1
6
4 4 2
2 9 3
2 6 3
2 5 9
2 2 2
2 3 3

예제 출력 1

76

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2007 J번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /