Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- ios_base::sync_with_stdio(false);
- int n, x;
- cin >> n >> x;
- vector<int> niza(n);
- for(int i = 0; i < n; i++){
- cin >> niza[i];
- }
- int s = 0;
- sort(niza.begin(), niza.end());
- for(int i = 0, j = n - 1; ;) {
- if(i > j) break;
- if(niza[i] + niza[j] <= x) {
- i++;
- j--;
- }
- else {
- j--;
- }
- s++;
- }
- cout << s << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement