CF1760F.Quests
普及/提高-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are n quests. If you complete the i-th quest, you will gain ai coins. You can only complete at most one quest per day. However, once you complete a quest, you cannot do the same quest again for k days. (For example, if k=2 and you do quest 1 on day 1, then you cannot do it on day 2 or 3, but you can do it again on day 4.)
You are given two integers c and d. Find the maximum value of k such that you can gain at least c coins over d days. If no such k exists, output Impossible. If k can be arbitrarily large, output Infinity.
共有 n 个任务。若你完成第 i 个任务,则将获得 ai 枚金币。你每天最多只能完成一个任务。然而,一旦你完成某个任务,接下来的 k 天内便不能再完成该任务。(例如,若 k=2,且你在第 1 天完成了任务 1,则你无法在第 2 天或第 3 天再次完成该任务,但可以在第 4 天再次完成。)
给你两个整数 c 和 d。请找出最大的 k 值,使得你能在 d 天内至少获得 c 枚金币。若不存在满足条件的 k,输出 Impossible;若 k 可以任意大,则输出 Infinity。
输入格式
The input consists of multiple test cases. The first line contains an integer t (1≤t≤104) — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers n,c,d (2≤n≤2⋅105; 1≤c≤1016; 1≤d≤2⋅105) — the number of quests, the number of coins you need, and the number of days.
The second line of each test case contains n integers a1,a2,…,an (1≤ai≤109) — the rewards for the quests.
The sum of n over all test cases does not exceed 2⋅105, and the sum of d over all test cases does not exceed 2⋅105.
输入包含多个测试用例。第一行包含一个整数 t(1≤t≤104),表示测试用例的数量。随后是各测试用例的描述。
每个测试用例的第一行包含三个整数 n,c,d(2≤n≤2⋅105;1≤c≤1016;1≤d≤2⋅105),分别表示任务数量、所需金币数以及天数。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(1≤ai≤109),表示各任务的奖励。
所有测试用例中 n 的总和不超过 2⋅105,所有测试用例中 d 的总和也不超过 2⋅105。
输出格式
For each test case, output one of the following.
- If no such k exists, output Impossible.
- If k can be arbitrarily large, output Infinity.
- Otherwise, output a single integer — the maximum value of k such that you can gain at least c coins over d days.
Please note, the checker is case-sensitive, and you should output strings exactly as they are given.
对于每个测试用例,输出以下选项之一:
- 如果不存在满足条件的 k,则输出
Impossible。 - 如果 k 可以任意大,则输出
Infinity。 - 否则,输出一个整数——即满足在 d 天内至少获得 c 枚硬币的最大 k 值。
请注意,评测程序区分大小写,您必须严格按照所给形式输出字符串。
输入输出样例
输入#1
6 2 5 4 1 2 2 20 10 100 10 3 100 3 7 2 6 4 20 3 4 5 6 7 4 100000000000 2022 8217734 927368 26389746 627896974 2 20 4 5 1
输出#1
2 Infinity Impossible 1 12 0
说明/提示
In the first test case, one way to earn 5 coins over 4 days with k=2 is as follows:
- Day 1: do quest 2, and earn 2 coins.
- Day 2: do quest 1, and earn 1 coin.
- Day 3: do nothing.
- Day 4: do quest 2, and earn 2 coins.
In total, we earned 2+1+2=5 coins.
In the second test case, we can make over 20 coins on the first day itself by doing the first quest to earn 100 coins, so the value of k can be arbitrarily large, since we never need to do another quest.
In the third test case, no matter what we do, we can't earn 100 coins over 3 days.
在第一个测试用例中,当 k=2 时,一种在 4 天内获得 5 枚硬币的方法如下:
- 第 1 天:完成任务 2,获得 2 枚硬币。
- 第 2 天:完成任务 1,获得 1 枚硬币。
- 第 3 天:不执行任何任务。
- 第 4 天:完成任务 2,获得 2 枚硬币。
总计获得 2+1+2=5 枚硬币。
在第二个测试用例中,我们仅在第一天即可通过完成第一个任务获得 100 枚硬币,从而赚取超过 20 枚硬币;因此 k 的值可以任意大,因为我们永远无需再完成其他任务。
在第三个测试用例中,无论采取何种策略,在 3 天内都无法获得 100 枚硬币。
输入解题思路,AI测评打分。不知道怎么写?