mirror of
https://github.com/wczffl-503/OI-Codes.git
synced 2025-07-07 18:06:58 +08:00
更新了许多
This commit is contained in:
32
李老师的书架.cpp
Normal file
32
李老师的书架.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <cmath>
|
||||
typedef long long l;
|
||||
typedef double d;
|
||||
typedef char c;
|
||||
using namespace std;
|
||||
int main(){
|
||||
long long a,b;
|
||||
long long c[100000],d[100000],cnt=0,sum=0;
|
||||
cin >>a>>b;
|
||||
for(int i=0;i<a;i++){
|
||||
cin >>c[i];
|
||||
}
|
||||
sort(c,c+a);
|
||||
for(int i=a-1;i>=0;i--){
|
||||
d[a-i-1]=c[i];
|
||||
}
|
||||
for(int i=0;i<a;i++){
|
||||
sum+=d[i];
|
||||
cnt++;
|
||||
if(sum>b){
|
||||
break;
|
||||
}
|
||||
}
|
||||
cout <<cnt;
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user