No.8090 Knapsack Function
問題文最終更新日: 2022-03-22 22:08:40
English (AI translation)
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
yukicoder April Fool Contest 2022
(順位表)
の他の問題:
Problem Statement
There are $N$ items. The $i \ (1 \leq i \leq N)$-th item has value $v_i$ and weight $w_i$.
For a non-negative integer $W$, define $f(W)$ as follows.
- When choosing some items so that their total weight is equal to $W$, let $f(W)$ be the maximum possible total value of the chosen items. Here, the same item may be chosen multiple times. If it is impossible to choose items so that their total weight is equal to $W$, let $f(W)=-1$.
Input
$N$ $v_1 \ w_1$ $v_2 \ w_2$ $\vdots$ $v_N \ w_N$
The input satisfies the following constraints.
- All input values are integers.
- $1 \leq N \leq 10^5$
- $1 \leq v_i \leq 10^9 \ (1 \leq i \leq N)$
- $1 \leq w_i \leq 10^9 \ (1 \leq i \leq N)$
Output
Print Yes if $f$ is monotonically increasing, and No otherwise.
Sample
There are no samples.提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
SSRS
sak