# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937895 | Litusiano | Self Study (JOI22_ho_t2) | C++17 | 431 ms | 7520 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;
int tot = 0;
for(int i = 0; i<n; i++){
int z = max(v[i].first, v[i].second); // a la clase i, estudio o hi vaig
int k = (mid+z-1)/z; // numero de veces que tengo que estudiar o ir
if(k <=m){
tot += k; continue;
}
tot+=m;
tot+= ((mid-z*m) + v[i].second-1)/v[i].second;
}
return tot<=n*m;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
v.resize(n);
for(auto& x : v) cin>>x.first; //a
for(auto& x : v) cin>>x.second; //b
int l = 1; int r = 1e18;
while(r > l+1){
int mid = (l+r)/2;
if(check(mid)) l = mid;
else r = mid;
}
cout<<l<<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... |