問題一覧 > 通常問題

No.2329 Nafmo Cheats

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 78
作問者 : Nafmo2 / テスター : dyktr_06 hikikomori sepa38
お気に入りにしたユーザー ProblemId : 9545 / 自分の提出
問題文最終更新日: 2026-10-19 10:20:58
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
MMA Contest 015 (順位表) の他の問題:

Problem Statement

Nafmo is taking part in an unusual game at a casino.
The game is played with $N$ playing-card-like cards.

The $N$ cards have the numbers $A_1,A_2, \dots,A_N$ written on their front faces, respectively, and their back faces are indistinguishable.

The participants, $1$ person at a time, determine their scores by following the procedure below. Among the participants with a score of at most $M$, the one with the highest score wins.

Nafmo, who has been granted supernatural powers, can use clairvoyance. He can draw a card with any number he aims for from among the face-down cards.
Using his powers, Nafmo obtained the maximum score he could achieve among scores of at most $M$.

What score did Nafmo obtain?

Rules of the game


  1. The initial score is $0$ points.
  2. If the number of cards drawn so far is less than $K$, choose whether or not to draw a card.
    • If drawing a card, choose $1$ card from among the $N$ shuffled, indistinguishable cards lying face down.
    • Add the number written on the chosen card to the score.
    • Put the card back and return to step 2.
  3. The procedure ends once $K$ cards have been drawn or the choice not to draw a card has been made.

Input

$N\ M \ K$
$A_1\ A_2\ \dots \ A_N$
  • $1 \leq N \leq 100$
  • $0 \leq M \leq 6 \times \max(A)$
  • $1 \leq K \leq 6$
  • $0 \leq A_i \leq 10^9$
  • All inputs are integers.

Output

Print the score Nafmo obtained to standard output.

Sample

Sample 1
Input
3 10 4
1 2 3 
Output
10

In this case, Nafmo can achieve a score of $10$ by drawing cards $4$ times: $2,2,3,3$. Since $M=10$, the score must be at most $10$, so the answer is $10$.

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

In this case, Nafmo's score must be at most $0$ points, so he does not draw even $1$ card.

Sample 3
Input
2 1 6
1 2
Output
1

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