Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Codeforces 149A
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int k, g[12], n=11, ans=0;
- cin >> k;
- for(int i=0;i<12;i++)
- {
- cin >> g[i];
- }
- sort(g, g+12);
- while(k>0)
- {
- k-=g[n];
- n--;
- ans++;
- if(ans==13){ans=-1;break;}
- }
- cout << ans;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment