rengetsu

Codeforces_149A

Oct 17th, 2018
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. //Codeforces 149A
  2. #include <iostream>
  3. #include <algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7.     int k, g[12], n=11, ans=0;
  8.     cin >> k;
  9.     for(int i=0;i<12;i++)
  10.     {
  11.         cin >> g[i];
  12.     }
  13.     sort(g, g+12);
  14.     while(k>0)
  15.     {
  16.         k-=g[n];
  17.         n--;
  18.         ans++;
  19.         if(ans==13){ans=-1;break;}
  20.     }
  21.     cout << ans;
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment