标签:一点 mirror cst scan pac out 个数 inf clu
2333
6
1 #include <iostream> 2 #include <cstdio> 3 #include <map> 4 #include <string> 5 #include<cstring> 6 #include<algorithm> 7 #include<vector> 8 typedef long long ll; 9 const int maxn = 1010000; 10 using namespace std; 11 int n, m,res; 12 int a[maxn]; 13 int b[maxn]; 14 int main() 15 { 16 int n, m; 17 while (cin >> n >> m,n!=0&&m!=0) 18 { 19 int k = 0; 20 for (int i = 0; i < n; i++) 21 scanf("%d", &a[i]); 22 for (int i = 0; i < n; i++) 23 for (int j = 0; j < n; j++) 24 b[k++] = a[i] + a[j]; 25 sort(b, b + k); 26 int Max = -1; 27 for (int i = 0; i < k; i++) 28 { 29 int temp = upper_bound(b, b + k, m - b[i]) - b; 30 if (temp - 1 < 0) continue; 31 Max = max(Max, b[i] + b[temp - 1]); 32 } 33 cout << Max << endl; 34 } 35 return 0; 36 }
标签:一点 mirror cst scan pac out 个数 inf clu
原文地址:https://www.cnblogs.com/kangdong/p/9440967.html