1731: 找和最接近但不超过K的两个元素
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
在一个长度为n(1 < n < 1000)的整数(0至1000之间)序列中,选出两个元素使得它们的和最接近但不超过K(0 <= K < 2000)。保证一定存在不超过K的两元素和。
Input
第一行输入一个整数n 第二行输入一个整数K 第三行输入序列,用空格分开
Output
最接近但不超过K的和
Sample Input Copy
4
7
1 2 2 8
Sample Output Copy
4