# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
527996 | amukkalir | Self Study (JOI22_ho_t2) | C++17 | 473 ms | 7120 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define prn printf
#define scn scanf
ll n, m;
const int nax = 3e5;
int a[nax+5], b[nax+5];
ll updiv(ll a, ll b) {
ll ret = a/b;
if(b*ret!=a) ret++;
return ret;
}
bool ok (ll x) {
ll jum = 0;
for(int i=0; i<n; i++) {
ll rem = x;
ll cur = 0;
if(a[i] > b[i]) {
cur += min(m, updiv(x, a[i]));
rem -= cur*a[i];
}
if(rem > 0) {
cur += updiv(rem, b[i]);
}
//cerr << i << " " << cur << endl;
jum += cur;
}
return jum <= n*m;
}
signed main () {
scn("%lld %lld", &n, &m);
for(int i=0; i<n; i++) scn("%d", &a[i]);
for(int i=0; i<n; i++) scn("%d", &b[i]);
ll ans = 0;
ll lo = 1, hi = 1e18;
while(lo <= hi) {
ll mid = (lo+hi)>>1;
if(ok(mid)) {
ans = mid;
lo = mid+1;
} else hi = mid-1;
}
prn("%lld", ans);
}
/*
binser
cek (x)
coba self study semua
coba kalo nambahin dtg bsb erkurang ga harinya
jumlahin harinya hrs less than or equal n*m
*/
컴파일 시 표준 에러 (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... |