#include <bits/stdc++.h>
using namespace std;
int w, n, a[30005], ans, k[30005];
int main() {
scanf("%d %d", &w, &n);
for (int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
}
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; i++) {
if (k[i] == 1)
continue;
int sum = 0, l = 0;
for (int j = n; j >= i + 1; j--) {
if (k[j] == 0)
if (a[j] + a[i] <= w) {
l = j;
break;
}
}
ans++;
k[l] = 1;
k[i] = 1;
}
printf("%d", ans);
return 0;
}
共 1 条回复