SHARE
TWEET

Untitled

a guest Jul 17th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int n, m, k, t;
  4. int kstill = 0;
  5. int t1, t2,t3;
  6. string crops[3] = {"Carrots","kiwis","Grapes"};
  7. int idl(int t1h,int t2h)
  8. {
  9.     int ret;
  10.     ret = ((t1h)*m)+t2h;
  11.     return ret;
  12. }
  13. bool valid(int id,int value,vector<int> &gap){
  14.     return gap[value]<= id;
  15. }
  16. int waste(int id,vector<int> &gap )
  17. {
  18.     int minx = 0,maxx = gap.size()-1,mid,ans;
  19.     while(minx<=maxx){
  20.         mid = (minx+maxx)/2;
  21.         if(valid(id,mid,gap)){
  22.             maxx = mid-1;
  23.         }else{
  24.             minx = mid+1;
  25.             ans = mid;
  26.         }
  27.     }
  28.     cout<<ans<<endl;
  29.     return ans;
  30. }
  31. int main()
  32. {
  33.     vector<int> gap;
  34.     cin>>n>>m>>k>>t;
  35.     gap[0] = 0;
  36.     for(int i = 0 ; i<k ; i++)
  37.     {
  38.         cin>>t1>>t2;
  39.         kstill += 1;
  40.         gap[kstill] = idl(t1,t2);
  41.     }
  42.     for(int i = 0 ; i<t ; i++)
  43.     {
  44.         cin>>t1>>t2;
  45.         int id = idl(t1,t2);
  46.         int w = waste(id,gap);
  47.         if(w==-1){
  48.             cout<<"Waste\n";
  49.         }else{
  50.             id -=w;
  51.             cout<<crops[id%3]<<"\n";
  52.         }
  53.  
  54.     }
  55. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top