1048. Find Coins (25)
时间限制
50 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. However, there was a special requirement ofthe payment: foreach bill, she could only use exactly two coins to pay the exact amount. Since she has as many as105 coins with her, she definitely needs your help. You are supposed to tell her, forany given amount of money, whether ornot she can find two coins to pay forit.
Input Specification:
Each input filecontainsone test case. For eachcase, thefirstlinecontains2 positive numbers: N (<=105, the total numberof coins) and M(<=103, the amount of money Eva has to pay). The secondlinecontains N face values ofthe coins, which are all positive numbers no more than 500. All the numbers inaline are separated byaspace.
Output Specification:
For each test case, print inonelinethetwo face values V1 and V2 (separated byaspace) such that V1 + V2 = M and V1 <= V2. If such a solution is not unique, output theonewiththe smallest V1. If there is no solution, output "No Solution" instead.
Sample Input 1:
8151287241115
Sample Output 1:
411
Sample Input 2:
714187241115
Sample Output 2:
No Solution