Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main(){
- int a,b;
- scanf("%d %d", &a, &b);
- int soma=0;
- vector<int>ordem;
- for(int i=0; i<a; i++){
- int x;
- scanf("%d", &x);
- ordem[i]=x;
- }
- while(1){
- int ok=0;
- for(int j=0; j<a-1; j++){
- if(ordem[j]<ordem[j+1]){
- swap(ordem[j], ordem[j+1]);
- ok=1;
- }
- }
- if (ok=0)break;
- }
- for(int m=0; m<a-1; m++){
- soma+=ordem[m];
- if(soma>b) {
- printf("%d\n", (int)ordem.size());
- break;}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement