이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |