欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1760F.Quests
Quests
There are quests. If you complete the -th quest, you will gain 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 days. (For example, if and you do quest on day , then you cannot do it on day or , but you can do it again on day .)
You are given two integers and . Find the maximum value of such that you can gain at least coins over days. If no such exists, output Impossible. If can be arbitrarily large, output Infinity.
Input
The input consists of multiple test cases. The first line contains an integer () — the number of test cases. The description of the test cases follows.
The first line of each test case contains three integers (; ; ) — the number of quests, the number of coins you need, and the number of days.
The second line of each test case contains integers () — the rewards for the quests.
The sum of over all test cases does not exceed , and the sum of over all test cases does not exceed .
Output
For each test case, output one of the following.
- If no such exists, output
Impossible. - If can be arbitrarily large, output
Infinity. - Otherwise, output a single integer — the maximum value of such that you can gain at least coins over days.
Please note, the checker is case-sensitive, and you should output strings exactly as they are given.
Note
In the first test case, one way to earn coins over days with is as follows:
- Day 1: do quest 2, and earn coins.
- Day 2: do quest 1, and earn coin.
- Day 3: do nothing.
- Day 4: do quest 2, and earn coins.
In total, we earned coins.
In the second test case, we can make over coins on the first day itself by doing the first quest to earn coins, so the value of 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 coins over days.
Samples
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
2
Infinity
Impossible
1
12
0
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |