Submission #526868

# Submission time Handle Problem Language Result Execution time Memory
526868 2022-02-16T12:43:30 Z eecs Self Study (JOI22_ho_t2) C++17
54 / 100
263 ms 8020 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 300010;
int n, m;
ll a[maxn], b[maxn];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &b[i]);
    }
    auto chk = [&](ll lim) {
        __int128 sum = 0;
        for (int i = 1; i <= n; i++) {
            ll rem = lim;
            if (a[i] > b[i]) {
                ll t = min(1LL * m, (lim + a[i] - 1) / a[i]);
                sum += t, rem -= t * a[i];
            }
            sum += (rem + b[i] - 1) / b[i];
        }
        return sum <= 1LL * n * m;
    };
    ll l = 0, r = 1e18, ans;
    while (l <= r) {
        ll mid = (l + r) / 2;
        chk(mid) ? l = (ans = mid) + 1 : r = mid - 1;
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%lld", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
Main.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf("%lld", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 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 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 87 ms 4656 KB Output is correct
10 Correct 62 ms 2700 KB Output is correct
11 Correct 44 ms 1988 KB Output is correct
12 Correct 38 ms 1716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 4 ms 352 KB Output is correct
19 Correct 3 ms 432 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 226 ms 5300 KB Output is correct
22 Correct 178 ms 5744 KB Output is correct
23 Correct 173 ms 6188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 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 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 87 ms 4656 KB Output is correct
10 Correct 62 ms 2700 KB Output is correct
11 Correct 44 ms 1988 KB Output is correct
12 Correct 38 ms 1716 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 1 ms 288 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 4 ms 352 KB Output is correct
19 Correct 3 ms 432 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 226 ms 5300 KB Output is correct
22 Correct 178 ms 5744 KB Output is correct
23 Correct 173 ms 6188 KB Output is correct
24 Correct 36 ms 1368 KB Output is correct
25 Correct 89 ms 3268 KB Output is correct
26 Correct 21 ms 964 KB Output is correct
27 Correct 170 ms 6660 KB Output is correct
28 Correct 174 ms 6612 KB Output is correct
29 Correct 175 ms 6632 KB Output is correct
30 Correct 182 ms 6772 KB Output is correct
31 Correct 225 ms 8020 KB Output is correct
32 Correct 263 ms 5588 KB Output is correct
33 Correct 258 ms 6644 KB Output is correct
34 Correct 231 ms 5028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -