Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n, k;
- cin >> n >> k;
- int a[n];
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- sort(a, a + n);
- int i = 0;
- int j = n - 1;
- int res = 0;
- while(i <= j) {
- if(a[i] + a[j] <= k) {
- i++;
- j--;
- }
- else {
- j--;
- }
- res++;
- }
- cout << res << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment