Store Credit (Large)
Time limit5sMemory limit512 MB
For each test case, find the two item positions whose prices sum to the credit C, and print the smaller position first.
Problem
A local store gives you a credit of , and you want to spend all of it on exactly two items.
You first walk through the store and write down the price of every item on sale, in order, forming a list . From this list you pick two items whose prices add up to exactly the credit.
The answer is the pair of positions those two items occupy in the list. The first item in the list is at position 1, and the smaller position is written first.
Input
The first line contains the number of test cases . test cases follow, each made of three lines.
- The first line contains , the credit you have at the store.
- The second line contains , the number of items in the store.
- The third line contains prices separated by spaces, in the order you wrote them down.
Each test case has exactly one solution: only one pair of positions has prices adding up to .
Limits
Output
For each test case, print one line containing Case #x: followed by the positions of the two items whose prices add up to the credit, separated by a space. Here is the test case number starting from 1, and the lower position comes first.