# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528025 | 2022-02-19T02:44:48 Z | amukkalir | Self Study (JOI22_ho_t2) | C++17 | 483 ms | 5060 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define prn printf #define scn scanf ll n, m; const int nax = 3e5; ll a[nax+5], b[nax+5]; ll updiv(ll a, ll b) { ll ret = a/b; if(ret*b < 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); ll ans = 1e9; for(int i=0; i<n; i++) scn("%lld", &a[i]); for(int i=0; i<n; i++) scn("%lld", &b[i]); for(int i=0; i<n; i++) ans = min(ans, max(a[i], b[i])); ll lo = ans, 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 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 237 ms | 4936 KB | Output is correct |
12 | Correct | 203 ms | 4916 KB | Output is correct |
13 | Correct | 154 ms | 4932 KB | Output is correct |
14 | Incorrect | 483 ms | 5060 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 276 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 94 ms | 3528 KB | Output is correct |
10 | Correct | 60 ms | 2580 KB | Output is correct |
11 | Correct | 43 ms | 2112 KB | Output is correct |
12 | Correct | 35 ms | 1816 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Incorrect | 5 ms | 332 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 237 ms | 4936 KB | Output is correct |
12 | Correct | 203 ms | 4916 KB | Output is correct |
13 | Correct | 154 ms | 4932 KB | Output is correct |
14 | Incorrect | 483 ms | 5060 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 0 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 276 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 1 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 94 ms | 3528 KB | Output is correct |
10 | Correct | 60 ms | 2580 KB | Output is correct |
11 | Correct | 43 ms | 2112 KB | Output is correct |
12 | Correct | 35 ms | 1816 KB | Output is correct |
13 | Correct | 1 ms | 204 KB | Output is correct |
14 | Correct | 0 ms | 204 KB | Output is correct |
15 | Correct | 0 ms | 204 KB | Output is correct |
16 | Correct | 0 ms | 204 KB | Output is correct |
17 | Correct | 1 ms | 204 KB | Output is correct |
18 | Incorrect | 5 ms | 332 KB | Output isn't correct |
19 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Correct | 0 ms | 204 KB | Output is correct |
4 | Correct | 0 ms | 204 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
6 | Correct | 1 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 0 ms | 204 KB | Output is correct |
9 | Correct | 1 ms | 204 KB | Output is correct |
10 | Correct | 3 ms | 332 KB | Output is correct |
11 | Correct | 237 ms | 4936 KB | Output is correct |
12 | Correct | 203 ms | 4916 KB | Output is correct |
13 | Correct | 154 ms | 4932 KB | Output is correct |
14 | Incorrect | 483 ms | 5060 KB | Output isn't correct |
15 | Halted | 0 ms | 0 KB | - |