제출 #1018786

#제출 시각아이디문제언어결과실행 시간메모리
1018786vjudge1Self Study (JOI22_ho_t2)C++17
0 / 100
134 ms4956 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define tobit(n) bitset<20>(n) //выводит 20 элементов в битовую систему #define all(v) (v).begin(), (v).end() #define rtt(v, k) rotate(v.begin(), v.begin() + k, v.end()); //move k elements back signed main(){ int n, m; cin >> n >> m; vector<int> a(n); vector<int> b(n); for(auto &to : a) cin >> to; for(auto &to : b) cin >> to; int l = 0; int r = 1e18 + 6; auto check = [&](int p){ int t = 0; for(int i = 0; i < n; i++){ if(b[i] > a[i]){ int b_ = (p + b[i] - 1) / b[i]; t += b_; } else { if(a[i] * 1ll * m >= p){ int a_ = (p + a[i] - 1) / a[i]; t += a_; } else { int a_ = m; int b_ = (p - a[i] * 1ll * a_ + b[i] - 1) / b[i]; t += a_ + b_; } } } if(t <= n * 1ll * m) return true; else return false; }; while(r > l + 1){ int m = (l + r) / 2; if(check(m)) l = m; else r = m; } cout << l; } // NEED TO FAST CIN && COUT // const int fastIO = [](){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...