0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-18 10:52:00 +00:00
OI-codes/Luogu/P1094/P1094.cpp

26 lines
436 B
C++
Raw Normal View History

2020-10-15 13:36:41 +00:00
#include <bits/stdc++.h>
using namespace std;
int main() {
int w, n, ans = 0, p[30005];
cin >> w >> n;
for (int i = 0; i < n; i++) {
cin >> p[i];
}
sort(p, p + n);
int l = 0, r = n - 1;
while (l <= r) {
if (p[l] + p[r] <= w) {
l++;
r--;
ans++;
2021-11-19 09:01:13 +00:00
} else {
2020-10-15 13:36:41 +00:00
r--;
ans++;
}
}
cout << ans << endl;
return 0;
}