이 제출은 이전 버전의 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
vector<pair<int, int>> v;
int n, m;
bool check(int MID){
vector<int> cur(n, 0);
int result = 0;
for(int i = 0; i < n && result <= n * m; i++){
int z = max(v[i].ff, v[i].ss);
int k = (MID + z - 1) / z;
if(k >= m){
result += m; cur[i] = MID - m * z;
result += (cur[i] + v[i].ss - 1) / v[i].ss;
} else result += k;
} return result <= n * m;
}
signed main(){
cin >> n >> m;
v.assign(n, {0, 0});
for(auto &to : v) cin >> to.ff;
for(auto &to : v) cin >> to.ss;
int l = 0; int r = 1e18 + 6;
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... |