問題一覧 > 通常問題

No.1454 Stop Deleting Tbeets Easy

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 155
作問者 : sushitoruna / テスター : oliverx3 MtSaka
お気に入りにしたユーザー ProblemId : 6082 / 自分の提出
問題文最終更新日: 2021-03-31 12:35:30
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
新入生プログラミングコンテスト 2021(夜の部) (順位表) の他の問題:

Problem Statement

Sushitoruna-kun uses a social network called $Tbutter$.
Currently, Sushitoruna-kun has $N$ tbeets. The $i$-th tbeet of Sushitoruna-kun has $A_i$ likes. Since he does not want to become a Tbutter addict, Sushitoruna-kun has decided to delete tbeets so that his number of tbeets becomes $M$ or less.
Simply deleting tbeets would be boring, so Sushitoruna-kun wants to maximize the sum of the likes of the remaining tbeets.
Tbeets with $Y$ likes or fewer are boring, so Sushitoruna-kun must delete them. Tbeets with $X$ likes or more are interesting, so he cannot delete them. For all other tbeets, he may freely decide whether to delete them or not.
Find the maximum possible sum of the likes of the remaining tbeets. However, if the number of tbeets cannot be made $M$ or less no matter how he deletes them, print Handicapped.

Input

$N\ M\ X\ Y$
$A_1\ A_2\ A_3\ ... A_N$

Constraints
$1 ≤ M ≤ N ≤ 10^5$
$0 ≤ Y < X ≤ 10^5$
$0 ≤ A_i ≤ 10^5$ ($1 ≤ i ≤ N$)
All inputs are integers.

Output

Regarding making the number of tbeets $M$ or less, Sushitoruna-kun's result should be output as follows:
- if it is impossible, print Handicapped;
- if it is possible, print the maximum possible sum of the likes of the remaining tbeets;
in either case on $1$ line. Print a newline at the end.

Sample

Sample 1
Input
9 6 7 2
1 3 2 5 4 7 6 8 9
Output
39

Tbeets number $6$ , $8$ , $9$ have $7$ likes or more, so they must be kept.
Also, tbeets number $1$ , $3$ have $2$ likes or fewer, so they must be deleted.
An example that satisfies these conditions and maximizes the total number of likes is to delete tbeets number $1$ , $2$ , $3$ .

Sample 2
Input
5 2 3 0
0 4 3 6 100
Output
Handicapped

All tbeets except tbeet number $1$ must be kept, so the number of tbeets cannot be reduced to $2$ or less.

Sample 3
Input
6 3 6 3
2 3 3 100 1 1
Output
100

Be careful of cases where many tbeets must be deleted.

Sample 4
Input
5 2 3 2
1 2 1 2 1
Output
0

If all tbeets are deleted, the total number of likes is $0$ .

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。