ccbeginner

TNFSHOJ 556

Oct 21st, 2020 (edited)
53
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4. #define SZ(X) (int)(X).size()
  5.  
  6. int arr[100000], brr[100000];
  7.  
  8. int32_t main(){
  9.     int n,k,m;
  10.     cin >> n >> k >> m;
  11.     for(int i = 0; i < n; ++i){
  12.         cin >> arr[i];
  13.     }
  14.     for(int i = 0; i < n; ++i){
  15.         cin >> brr[i];
  16.     }
  17.     int big = k, small = 0;
  18.     while(big >= small){
  19.         int mid = (big + small) / 2;
  20.         int cnt = 0;
  21.         for(int i = 0; i < n; ++i){
  22.             int val = max(k - arr[i] * mid, 0LL);
  23.             if(val % brr[i] == 0)cnt += val/brr[i];
  24.             else cnt += val/brr[i] + 1;
  25.         }
  26.         //cout << mid << ' ' << cnt << '\n';
  27.         if(cnt > m){
  28.             small = mid + 1;
  29.         }else{
  30.             big = mid - 1;
  31.         }
  32.     }
  33.     cout << small << '\n';
  34.     return 0;
  35. }
RAW Paste Data