Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
why wrong?thanks#include<iostream> #include<algorithm> using namespace std; inline bool cmp(char a,char b) { return a>b; } int a[20003]; int main() { long int n,m,i,sum=0; cin>>n>>m; for(i=0;i<n;i++) cin>>a[i]; sort(a,a+n,cmp); i=0; while(sum<m) sum+=a[i++]; cout<<i<<endl; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator