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

23851번 - Akcija 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 512 MB466515.152%

문제

Christmas, a time for giving. Mr. Malnar is in need of gift ideas. Although deep in thought, the television program grabs his attention: “Special offer! This amazing product is on sale for just $w$ kunas. Call now because the offer is available only if you call within the next $d$ minutes. But that’s not all...”

There are $n$ different products on sale, where the $i$-th product has a cost of $w_i,ドル and it’s available for order until the minute $d_i$ (inclusive). Making a call to place an order requires one minute. A subset of products is called obtainable if it is possible to make a sequence of calls which order those products while meeting the mentioned deadlines. No product can be ordered more than once.

Mr. Malnar intends to buy as many products as possible, at the least possible price, but he’s not yet sure which products he should buy. He compares two obtainable subsets in the following way: the better obtainable subset is the one with more products, and if they have equal size, it’s the one that has a smaller total cost (sum of costs of chosen products).

Mr. Malnar will rank the obtainable subsets in the described manner and he will take into consideration $k$ of the best ones. Write a program which determines the size and the total cost for $k$ of the best obtainable subsets.

입력

The first line contains positive integers $n$ and $k$ - the number of different products and the number of obtainable subsets to be taken into consideration, respectively. $k$ will be less than or equal to the total number of obtainable subsets.

The following $n$ lines contain two positive integers $w_i$ (1ドル ≤ w_i ≤ 10^9$) and $d_i$ (1ドル ≤ d_i ≤ n$) - the cost of the $i$-th product and the last minute for which the offers stands, respectively.

출력

In the i-th line print the size and the total cost of the i-th best obtainable subset.

제한

In every subtask, it holds that 1ドル ≤ n, k ≤ 2000$.

서브태스크

번호배점제한
110

$k = 1,ドル $w_1 = \dots = w_n$

220

$k = 1$

320

$k = 2$

410

1ドル ≤ n ≤ 20$

530

1ドル ≤ n, k ≤ 100$

620

No additional constraints.

예제 입력 1

3 1
1 1
1 1
1 3

예제 출력 1

2 2

예제 입력 2

4 3
1 1
10 1
2 3
10 3

예제 출력 2

3 13
3 22
2 3

예제 입력 3

2 4
1 1
2 2

예제 출력 3

2 3
1 1
1 2
0 0

힌트

Clarification of the second example: Products 1 and 2 can’t simultaneously be in an obtainable subset, so the three best obtainable subsets are {1, 3, 4}, {2, 3, 4} and {1, 3}.

출처

Contest > Croatian Open Competition in Informatics > COCI 2021/2022 > Contest #3 3번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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