王一诺唐氏

程序员王斌爱玩原神  •  1天前


include <bits/stdc++.h>

using namespace std;

int main() {

int n, m, sum = 0;
cin >> n >> m;
vector<int>a(n);
for (int i = 0; i < n; i++) {
	cin >> a[i];
}
sort(a.begin(), a.end());
int x = 0, y = n - 1;
while (x <= y) {
	if (a[x] + a[y] <= m) {
		x++;
		y--;
	} else {
		y--;
	}
	sum++;
}
cout << sum << endl;
return 0;

}


评论:

请先登录,才能进行评论