CF2248G.No Balance Left

NOI/NOI+/CTSC

通过率:0%

时间限制:6.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alisa has a shopping card with an initial balance of hh. There are nn types of products in a supermarket. A product of type ii costs cic_i, and Alisa can buy any number of products of each type.

There are also mm rebate activities. The jj-th activity applies to a purchase if its total cost is at least aja_j and gives a rebate of bjb_j.

For each purchase, Alisa performs the following operations:

  • She chooses one or more products whose total cost xx does not exceed the current balance on her card and pays xx using the card.
  • Among all rebate activities that apply to this purchase, the one with the largest rebate takes effect and its rebate is added to the card balance. If no rebate activity applies, no rebate is added.

For every hh from 11 to ss, determine whether Alisa can make the balance on her card equal to 00 after finitely many purchases.

Alisa 有一张初始余额为 hh 的购物卡。超市中有 nn 种商品,第 ii 种商品的单价为 cic_i,且 Alisa 可以购买任意数量的每种商品。

此外还有 mm 个返现活动。第 jj 个返现活动适用于总花费至少为 aja_j 的单次购物,并提供金额为 bjb_j 的返现。

每次购物时,Alisa 执行以下操作:

  • 她选择一种或多种商品,使其总花费 xx 不超过购物卡当前余额,并用该卡支付 xx 元;
  • 在所有适用于本次购物的返现活动中,返现金额最大的那个活动生效,其返现金额 bjb_j 被加到购物卡余额中;若没有适用的返现活动,则不增加任何返现。

对每个从 11 到 ss 的 hh,判断 Alisa 是否能在有限次购物后使购物卡余额恰好变为 00。

输入格式

The first line contains three integers nn, mm, and ss (1≤n,m,s≤125 0001 \le n, m, s \le 125\,000) — the number of product types, the number of rebate activities, and the maximum initial balance to consider, respectively.

The second line contains nn integers c1,c2,…,cnc_1, c_2, \ldots, c_n (1≤ci≤125 0001 \le c_i \le 125\,000) — the price of a product of each type.

The ii-th of the next mm lines contains two integers aia_i and bib_i (1≤ai,bi≤125 0001 \le a_i, b_i \le 125\,000) — the spending threshold and the rebate of the ii-th activity, respectively.

It is guaranteed that a1<a2<⋯<ama_1 \lt a_2 \lt \cdots \lt a_m and b1<b2<⋯<bmb_1 \lt b_2 \lt \cdots \lt b_m.

第一行包含三个整数 nn、mm 和 ss(1≤n,m,s≤125 0001 \le n, m, s \le 125\,000),分别表示商品种类数、返现活动数以及需考虑的最大初始余额。

第二行包含 nn 个整数 c1,c2,…,cnc_1, c_2, \ldots, c_n(1≤ci≤125 0001 \le c_i \le 125\,000),表示每种商品的价格。

接下来的 mm 行中,第 ii 行包含两个整数 aia_i 和 bib_i(1≤ai,bi≤125 0001 \le a_i, b_i \le 125\,000),分别表示第 ii 个返现活动的消费门槛和返现金额。

保证 a1<a2<⋯<ama_1 \lt a_2 \lt \cdots \lt a_m 且 b1<b2<⋯<bmb_1 \lt b_2 \lt \cdots \lt b_m。

输出格式

Print ss lines. For each ii (1≤i≤s1 \le i \le s), print "YES" if Alisa can make the balance on her card equal to 00 when its initial balance is ii, and print "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

输出 ss 行。对于每个 ii(1≤i≤s1 \le i \le s),若 Alisa 在卡片初始余额为 ii 时能够使其余额恰好变为 00,则输出 "YES";否则输出 "NO"。

答案的大小写不限(即大小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。

输入输出样例

  • 输入#1

    2 1 15
    4 7
    8 4

    输出#1

    NO
    NO
    NO
    YES
    NO
    NO
    YES
    YES
    NO
    NO
    YES
    YES
    NO
    YES
    YES
  • 输入#2

    5 3 25
    4 8 12 16 20
    6 8
    7 9
    8 10

    输出#2

    NO
    NO
    NO
    YES
    NO
    NO
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO
    YES
    NO

说明/提示

In the first example, Alisa can make the balance equal to 00 when the initial balance is 1515 as follows:

  • She buys one product of each type for a total cost of 4+7=114 + 7 = 11. The balance decreases from 1515 to 44.
  • Since 11≥811 \ge 8, the rebate of 44 takes effect. The balance increases from 44 to 88.
  • She buys one product of the first type for 44. No rebate activity applies, so the balance decreases from 88 to 44.
  • She buys one product of the first type again for 44. No rebate activity applies, so the balance decreases from 44 to 00.

Therefore, the 1515-th line of the first example output is "YES".

In the second example, if the initial balance is 44, Alisa can buy one product of the first type for 44. Since 4<64 \lt 6, no rebate activity applies, and the balance becomes 00. Therefore, the fourth line of the second example output is "YES". If the initial balance is 11, no product is affordable, so the first line is "NO".

在第一个例子中,当初始余额为 1515 时,阿丽萨可以按如下方式使余额变为 00:

  • 她购买每种类型的产品各一个,总花费为 4+7=114 + 7 = 11。余额从 1515 减少至 44。
  • 由于 11≥811 \ge 8,返现 44 生效。余额从 44 增加至 88。
  • 她再次购买一个第一类商品,花费 44。此时不满足返现条件,因此余额从 88 减少至 44。
  • 她再次购买一个第一类商品,花费 44。此时仍不满足返现条件,因此余额从 44 减少至 00。

因此,第一个例子输出的第 1515 行为 "YES"。

在第二个例子中,若初始余额为 44,阿丽萨可购买一个第一类商品,花费 44。由于 4<64 \lt 6,不触发返现,余额变为 00。因此,第二个例子输出的第四行为 "YES"。若初始余额为 11,则无法负担任何商品,故第一行为 "NO"。

输入解题思路,AI测评打分。不知道怎么写?

首页