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

20045번 - Trading System 다국어

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

문제

SY Company wants to improve its stock trading system. For this, the company decides to utilize the information on the fluctuation of the stock prices. The fluctuation value is the difference in stock prices for two consecutive days. The company collects n recent fluctuation values for some stock. It turns out that the stock volatility is greatly affected by the largest sum of the contiguous fluctuation values. Finding such contiguous fluctuation values whose sum is the maximum is known as the largest sum contiguous subarray problem in computer science, where input values are stored in an array. It is natural that utilizing the k(≥ 1) largest contiguous sums rather than the largest one will help improve the trading system.

Write a program to find the k largest sums of contiguous fluctuation values for the given n fluctuation values and a positive integer k.

입력

Your program is to read from standard input. The input starts with a line containing two integers, n and k, where 1 ≤ n ≤ 250,000 and 1 ≤ k ≤ min(10,000, n(n + 1)/2). The next line contains n integers representing n fluctuation values. All fluctuation values are between −109 and 109 inclusively.

출력

Your program is to write to standard output. Print exactly one line. The line should contain the k largest sums of contiguous fluctuation values in non-increasing order. Note that any contiguous sum is the sum of one or more consecutive fluctuation values.

제한

예제 입력 1

5 3
1 -2 -3 5 4

예제 출력 1

9 6 5

예제 입력 2

6 10
3 8 -3 2 5 2

예제 출력 2

17 15 14 12 11 10 9 8 8 7

힌트

출처

ICPC > Regionals > Asia Pacific > Korea > Nationwide Internet Competition > Seoul Nationalwide Internet Competition 2020 J번

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

출처

대학교 대회

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

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