SHARE
TWEET

lightoj - 1227 - Boiled Eggs

jakaria_hossain Aug 22nd, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top