Easy Beginners Problems > Ad-hoc

You receive a credit C at Meena Bazar and would like to buy two items. You first walk through to nearest Meena Bazar store and create a list of all available items. From this list you would like to buy three items that add up to the entire value of the credit. The solution you provide will consist of the three integers indicating the positions of the items in your list (smaller number first). You need to print only the lexicographically smallest order. Input: ------ The first line of input gives the number of cases, T. T test cases follow. For each test case there will be: - One line containing the value **C**, the amount of credit you have at the store. - One line containing the value **I**, the number of items in the store. - One line containing a space separated list of **I** integers. Each integer **P** indicates the price of an item in the store. Constraints: ------------ - 5 ≤ C ≤ 1000 - 1 ≤ P ≤ 1000 - T = 100 - 3 ≤ I ≤ 2000 Output: ------- For each test case, output one line containing **"Case x: "** followed by the indices of the three items whose price adds up to the store credit. The lower index should be output first. If you don’t found those three items which adds up store credit print "**You are out of your luck!**" See the sample **I/O**. Sample Input ------------ 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 Sample Output ------------- Case 1: You are out of your luck! Case 2: You are out of your luck! Case 3: 2 4 8

Rezwanul Islam Maruf

Language |
Time Limit (seconds) |

C | 1.00 |

C++ | 1.00 |

C++14 | 1.00 |

C# | 1.20 |

Go | 1.20 |

Java | 1.20 |

JavaScript | 1.20 |

Objective-C | 1.20 |

Perl | 1.20 |

PHP | 1.20 |

Python | 1.20 |

Python3 | 1.20 |

Ruby | 1.20 |

VB.Net | 1.20 |

Solve/Submission

# | User | Language | Timing |
---|---|---|---|

01 | subhashis_cse | Cpp | 0.01s |

02 | twyu0721 | C | 0.01s |

03 | celeste871103 | Cpp | 0.01s |

04 | wayne6172 | C | 0.01s |

05 | feodorv | C | 0.01s |

06 | souravahmed | C | 0.01s |

07 | Morass | Cpp14 | 0.03s |

08 | emrul | Cpp14 | 0.03s |

09 | tariqiitju | Cpp14 | 0.05s |

10 | jahirtheboss | Cpp14 | 0.09s |

11 | SONNET_N | Cpp14 | 0.16s |

12 | rajdipsaha | Cpp14 | 0.18s |

13 | J414N | Cpp14 | 0.25s |

14 | Taj025 | CSharp | 0.29s |

15 | rabbicse | CSharp | 0.31s |

16 | zahidbiscj | CSharp | 0.32s |

17 | abuasifkhan | Cpp14 | 0.32s |

18 | akbor | CSharp | 0.33s |

19 | moinul_shaon | Cpp14 | 0.34s |

20 | belal_mbstu | Cpp14 | 0.37s |

21 | dipta007 | Cpp14 | 0.42s |

22 | imranziad | Cpp14 | 0.43s |

23 | MAHRahat | Cpp14 | 0.43s |

24 | Matrix_code | Cpp14 | 0.44s |

25 | SugiuraAyano | C | 0.45s |

26 | Jumba | Cpp14 | 0.47s |

27 | Riaz_BSMRSTU | Cpp | 0.48s |

28 | daihan_mbstu | Cpp | 0.48s |

29 | prateepm | Cpp14 | 0.48s |

30 | akazad_cse13_ruet | Cpp14 | 0.49s |

31 | I_See_You | Cpp14 | 0.50s |

32 | Logic_Hunter | Cpp14 | 0.50s |

33 | sahedsohel | Cpp14 | 0.52s |

34 | ts01232165 | C | 0.53s |

35 | Shubhode | CSharp | 0.55s |

36 | ssavi | Cpp14 | 0.55s |

37 | fsshakkhor | Cpp14 | 0.57s |

38 | pulak_ict_mbstu | Cpp | 0.57s |

39 | zyyxxx | Cpp14 | 0.58s |

40 | abinash | Cpp14 | 0.60s |

41 | shuvo_iu | Cpp14 | 0.61s |

42 | shivazi | Cpp14 | 0.62s |

43 | nfssdq | Cpp14 | 0.62s |

44 | faisal47 | Cpp14 | 0.65s |

45 | mamun4122 | Cpp14 | 0.66s |

46 | mahbubcseju | Cpp14 | 0.67s |

47 | khatribiru | Cpp14 | 0.73s |

48 | Zayed | Cpp14 | 0.73s |

49 | mtmohim | Cpp14 | 0.74s |

50 | tashfiq123 | Cpp14 | 0.75s |

Copyright © 2015-2016 Dev Skill.

Feedback
#### Your feedback is our precious!

## Thank you for providing feedback! Our developers will be happy :)

## Sorry there was a problem when submitting the feedback. Please try again. :(