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

17920번 - Short Sell 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB27181789.474%

문제

Simone is learning to trade crypto currencies. Right now, she is looking into a new currency called CryptoKattis. A CryptoKattis can be used to improve your Kattis ranklist score without having to solve problems.

Simone, unlike most competitive programmers, is very perceptive of competition trends. She has lately noticed many coders talking about a new online judge called Doggo, and suspect that using the Kattis judge will soon fall out of fashion. This, of course, will cause the CryptoKattis to rapidly fall in value once demand fades.

To take advantage of this, Simone has performed very careful market research. This has allowed her to estimate the price of a CryptoKattis in dollars during the next $N$ days. She intends to use this data to perform a short sell. This means she will at some day borrow 100ドル$ CryptoKattis from a bank, immediately selling the currency. At some other day, she must purchase the same amount of CryptoKattis to repay her loan. For every day between (and including) these two days, she must pay $K$ dollars in interest. What is the maximum profit Simone can make by carefully choosing when to borrow and repay the 100ドル$ CryptoKattis?

입력

The first line of the input contains two integers 1ドル \le N \le 100,000円$ and 1ドル \le K \le 100$. $N$ is the number of days you know the CryptoKattis price of, and $K$ is the cost in dollars of borrowing CryptoKattis per day.

The next line contains $N$ integers separated by spaces. These are the CryptoKattis prices during the $N$ days. Each CryptoKattis price is between 1ドル$ and 100ドル,000円$ dollars.

출력

Output a single decimal number; the maximum profit you can make performing a short sell. If you cannot make a profit no matter what short sell you make, output 0ドル$.

제한

예제 입력 1

5 10
1000 980 960 940 10

예제 출력 1

98950

예제 입력 2

5 100
100 100 100 103 100

예제 출력 2

100

힌트

출처

Contest > Swedish Coding Cup > LiU Coding Challenge 2018 B번

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

출처

대학교 대회

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

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