| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1183817 | apelpisia | Self Study (JOI22_ho_t2) | C++20 | 122 ms | 5136 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll nx = 3e5+5;
ll n, m, a[nx], b[nx], l = 0, r = LLONG_MAX, md;
bool check(){
ll cnt = 0;
for(ll i=0; i<n; i++){
if(a[i]>b[i]){
if(a[i]*m>=md){
cnt+=(md/a[i]+(md%a[i]==0 ? 0 : 1));
} else{
cnt+=(m+(md-a[i]*m)/b[i]+((md-a[i]*m)%b[i]==0 ? 0 : 1));
}
} else{
cnt+=(md/b[i] + (md%b[i]==0 ? 0 : 1));
}
if(cnt>n*m) return false;
}
return true;
}
int main(){
cin.tie(NULL)->sync_with_stdio(false);
cin >> n >> m;
for(ll i=0; i<n; i++) cin >> a[i];
for(ll i=0; i<n; i++) cin >> b[i];
while(l<r){
md = l+(r-l)/2;
if(check()) l = md+1;
else r = md;
}
cout << l-1;
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... | ||||
