SuitNdtie

Bathroom set3

Apr 8th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<map>
  3. using namespace std;
  4. typedef long long int ll;
  5. bool debug = false;
  6. struct mycmp{
  7.     bool operator() (const ll& lhs,const ll& rhs)const
  8.     {
  9.         return lhs > rhs;
  10.     }
  11. };
  12.  
  13. int main()
  14. {
  15.     int T;
  16.     scanf("%d",&T);
  17.     map<ll,ll,mycmp> map;
  18.     for(int t = 1; t <= T ;t ++){
  19.         ll n,k;
  20.         scanf("%lld %lld",&n,&k);
  21.         map.clear();
  22.         map[n] = 1;
  23.         ll i = 0;
  24.         std::map<ll,ll>::iterator it;
  25.        
  26.         ll RE,LE;
  27.         while(i < k){
  28.             it = map.begin();
  29.             ll len = it->first;
  30.             ll cnt = it->second;
  31.             ll mid = (len + 1)/2;
  32.             RE = len - mid;
  33.             LE = mid - 1;
  34.             if(debug)printf("Test Case #%d : i = %d , len = %lld , cnt = %lld , mid = %lld , RE = %lld , LE = %lld\n",t,i,len,cnt,mid,RE,LE);
  35.             map.erase(len);
  36.             map[RE] += cnt;
  37.             map[LE] += cnt;
  38.             i += cnt;
  39.         }
  40.         printf("Case #%d: %lld %lld\n",t,RE,LE);
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment