# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937955 | Litusiano | Self Study (JOI22_ho_t2) | C++17 | 435 ms | 7488 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>
using namespace std;
#define int long long
#define endl "\n"
vector<pair<int,int>> v;
int n,m;
bool check(int mid){
vector<int> need(n,0);
int left = 0;
for(int i = 0; i<n; i++){
int z = max(v[i].first, v[i].second);
int z1 = z + mid -1;
int k = (z1)/z;
z*=m;
if(k > m) need[i] = mid-(z);
else left+=m-k;
}
for(int i = 0; i<n; i++){
int z = need[i];
z += v[i].second;
z--;
left -= (z)/v[i].second;
}
return left>=0;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
v.resize(n);
for(auto& x : v) cin>>x.first; for(auto& x : v) cin>>x.second;
int low = 0; int high = 1e18+5;
while(high > low+1){
int middle = (low+high)/2;
if(check(middle)) low = middle;
else high = middle;
}
cout<<low<<endl;
}
Compilation message (stderr)
# | 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... |