No.3014 岩井満足性問題
タグ : / 解いたユーザー数 165
作問者 :
ゆにたりー卿
👑
DeltaStruct
Rice_tawara459
のらら
あじゃじゃ
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. Show the original
Problem Statement
Iwai Seijin wants to be satisfied by the next programming contest, "ABC10000". Your job as the contest organizer is to adopt good problems from among the problem proposals while at the same time satisfying Iwai Seijin.
There are $N$ problem proposals, numbered $1, 2, ..., N$.
When problem proposal $i$ is adopted, Iwai Seijin gains $A_i$ of satisfaction. ($A_i$ may be negative.)
Also, problem proposal $i$ has a beauty of $C_i$.
Output the maximum satisfaction Iwai Seijin can gain when $D$ distinct problem proposals are adopted so that the total beauty is at least $K$.
However, if the total beauty cannot be at least $K$, output No.
Constraints
- $1\leq D\leq N\leq 500$
- $1\leq K\leq 500$
- $-10^9\leq A_i\leq 10^9$
- $0\leq C_i\leq 10^9$
- All input values are integers.
Input
The input is given from standard input in the following format.
$N\quad D\quad K$
$A_1\quad A_2\quad ... \quad A_{N-1} \quad A_N$
$C_1\quad C_2\quad ... \quad C_{N-1} \quad C_N$
Output
Output the maximum satisfaction that meets the conditions.
If it is impossible to meet the conditions, output No.
Sample
Sample 1
Input
5 3 20 20 10 -15 30 20 3 8 11 9 6
Output
60
When problem proposal $1$, problem proposal $2$, and problem proposal $4$ are adopted, the satisfaction is $60$ and the total beauty is $20$.
Sample 2
Input
1 1 500 3 10
Output
No
No contest that meets the conditions can be made.
Sample 3
Input
16 8 240 101 -202 300 400 -430 700 -720 820 -830 -890 910 -970 990 1013 -1250 1270 50 20 15 35 25 30 35 40 20 30 10 35 0 20 35 20
Output
4494
This can be achieved by adopting problem proposals $1,\ 4,\ 6,\ 7,\ 8,\ 11,\ 14,\ 16$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。