Advertisement
jakaria_hossain

lightoj - 1227 - Boiled Eggs

Aug 22nd, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. int main()
  5. {
  6. int te;
  7. cin>>te;
  8. for(int t=1;t<=te;t++)
  9. {
  10. int n,p,q,x=0;
  11. cin>>n>>p>>q;
  12. int ara[n+1];
  13. for(int i=0;i<n;i++)cin>>ara[i];
  14. sort(ara,ara+n);
  15. int i;
  16. for(i=0;i<n;i++)
  17. {
  18. if(i==p || x>=q)break;
  19. x+=ara[i];
  20. }
  21. if(x<=q)printf("Case %d: %d\n",t,i);
  22. else printf("Case %d: %d\n",t,i-1);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement