Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int n, x;
- cin >> n >> x;
- vector<int> weight;
- for(int i=0; i<n; i++){
- int input;
- cin >> input;
- weight.push_back(input);
- }
- sort(weight.begin(), weight.end());
- int count=0;
- while(weight.empty()==0){
- int first = weight[0];
- weight.erase(weight.begin());
- if(first+weight[0]<=x){
- count++;
- weight.erase(weight.begin());
- }else{
- count++;
- }
- }
- cout << count << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement