| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 651855 | beaconmc | Self Study (JOI22_ho_t2) | C++11 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
ll n,m;
vector<ll> lis;
vector<ll> lis2;
bool check(ll a){
ll cnt = 0;
FOR(i,0,n){
if (lis[i] > lis2[i]){
if (a>lis[i]*m){
cnt += (a-(lis[i]*m)-1)/lis2[i]+1 + m;
}else{
cnt += (a-1)/lis[i];
}
}else{
cnt += (a-1)/lis2[i];
}
}
if (cnt <= n*m){
return true;
}return false;
}
int main(){
ll lo = 0;
ll hi = 100000000000000000;
while (lo<hi){
ll mid = (lo+hi+1)/2;
if (check(mid)){
lo = mid;
}else{
hi = mid - 1
}
}
cout << lo;
}
