codeforce 609A - USB Flash Drives
生活随笔
收集整理的這篇文章主要介紹了
codeforce 609A - USB Flash Drives
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
排序水題
1 #include<iostream> 2 #include<cstdlib> 3 #include<cstdio> 4 #include<algorithm> 5 #include<math.h> 6 using namespace std; 7 8 int n,m; 9 int a[110]; 10 11 int main() 12 { 13 scanf("%d",&n); 14 scanf("%d",&m); 15 for(int i=0;i<n;i++) 16 { 17 scanf("%d",&a[i]); 18 } 19 sort(a,a+n); 20 int ans=0; 21 int num=0; 22 for(int i=n-1;i>=0;i--) 23 { 24 ans+=a[i]; 25 if(ans>=m) 26 { 27 num++; 28 break; 29 } 30 num++; 31 } 32 cout<<num<<endl; 33 return 0; 34 } View Code?
轉載于:https://www.cnblogs.com/ITUPC/p/5083528.html
總結
以上是生活随笔為你收集整理的codeforce 609A - USB Flash Drives的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: win10安装问题小结
- 下一篇: ubuntu15.04中安装mysql和