QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 1024 MB 總分: 14

#14001. Store Credit

统计

你在一家当地商店获得了 $C$ 元的购物金,并且想购买两件商品。你首先在商店里逛了一圈,并创建了一份包含所有可用商品的列表 $L$。你希望从这份列表中购买两件商品,使它们的价格之和正好等于购物金的总额。你提供的解决方案将由两个整数组成,表示这两件商品在列表中的位置(较小的索引在前,索引从 1 开始)。

输入格式

输入的第一行给出测试用例的数量 $N$。接下来是 $N$ 个测试用例。每个测试用例包含:

  • 一行,包含数值 $C$,即你在商店拥有的购物金金额。
  • 一行,包含数值 $I$,即商店中的商品数量。
  • 一行,包含由空格分隔的 $I$ 个整数。每个整数 $P$ 表示商店中某件商品的价格。
  • 每个测试用例有且仅有一个解。

输出格式

对于每个测试用例,输出一行,格式为 Case #x:,后跟两件商品的位置索引,其价格之和等于商店购物金。较小的索引应该先输出。

数据范围

小数据规模(8 分)

  • $5 \le C \le 1000$
  • $1 \le P \le 1000$
  • $N = 10$
  • $3 \le I \le 100$

大数据规模(25 分)

  • $5 \le C \le 1000$
  • $1 \le P \le 1000$
  • $N = 50$
  • $3 \le I \le 2000$

样例

输入样例 1

3
100
3
5 75 25
200
7
150 24 79 50 88 345 3
8
8
2 1 9 4 4 56 90 3

输出样例 1

Case #1: 2 3
Case #2: 1 4
Case #3: 4 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.