이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>
#include <bitset>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <queue>
#include <cstring>
#include <fstream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll, ll>
#define pii pair<int, int>
#define f first
#define s second
#define inf 1000000000000000
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n, m;
cin >> n >> m;
ll a[n], b[n];
for(int i=0;i<n;i++) cin >> a[i];
for(int i=0;i<n;i++) cin >> b[i];
ll l=0, r=1e18+1, mid;
while(r-l!=1){
//cout << l << " " << r << endl;
mid=(l+r)/2;
ll cnt=n*m;
vector<pll> todo;
for(int i=0;i<n;i++){
if(a[i]>=b[i]){
if(a[i]*m>=mid) cnt-=(mid+a[i]-1)/a[i];
else cnt-=m+(mid-a[i]*m+b[i]-1)/b[i];
}else cnt-=(mid+b[i]-1)/b[i];
}
if(cnt>=0) l=mid;
else r=mid;
}
cout << l << endl;
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... |