답안 #923745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923745 2024-02-07T17:18:00 Z shahd_abbara Self Study (JOI22_ho_t2) C++17
100 / 100
480 ms 9040 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define what(x) cout << (#x) << " -> " << x << '\n';
#define endl '\n'
#define cno cout << "NO" \
                 << "\n"
#define cy cout << "YES" \
                << "\n"
#define c1 cout << "-1" << '\n'
#define pb push_back
#define ff first
#define ss second
#define sz size()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

const ll N = 1000005;
const ll mod = 1000000007;

ll n, m, k, l, r, q, d, x, y, z, id, ind, pointer, point, next, curr, temp;
ll mn = 2e18, mx = 0, Maxmx = 0, Ans = 0, cost = 0, prod = 1, tot = 0, sum = 0;
ll a[N], arr[N], b[N];
vector<ll> v;
string s, t;
bool ok(ll mid)
{
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {

        temp = mid;
        x = (temp + max(a[i], b[i]) - 1) / max(a[i], b[i]);
        temp -= min(min(m, x) * max(a[i], b[i]), temp);

        y = (temp + b[i] - 1) / b[i];
        ans += min(x, m) + y;
        if (ans > m * n)
            return 0;
    }

    return 1;
}
void solve()
{
    cin >> n >> m;
    x = 1;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
    }
    ll lo = 1, hi = 1;
    while (ok(hi))
        hi *= 2;

    while (lo < hi)
    {
        ll mid = (lo + hi + 1) / 2;

        if (ok(mid))
            lo = mid;
        else
            hi = mid - 1;
    }
    cout << lo << endl;
}
int main()
{
    IOS int testcases = 1;

    // cin >> testcases;
    while (testcases--)
    {

        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8832 KB Output is correct
12 Correct 158 ms 8788 KB Output is correct
13 Correct 180 ms 8660 KB Output is correct
14 Correct 169 ms 8840 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 29 ms 8852 KB Output is correct
17 Correct 196 ms 8828 KB Output is correct
18 Correct 111 ms 8788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 29 ms 8852 KB Output is correct
3 Correct 196 ms 8828 KB Output is correct
4 Correct 111 ms 8788 KB Output is correct
5 Correct 1 ms 2552 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 0 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 0 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 94 ms 6780 KB Output is correct
14 Correct 63 ms 4720 KB Output is correct
15 Correct 45 ms 4700 KB Output is correct
16 Correct 43 ms 4728 KB Output is correct
17 Correct 2 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 0 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 4 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8832 KB Output is correct
12 Correct 158 ms 8788 KB Output is correct
13 Correct 180 ms 8660 KB Output is correct
14 Correct 169 ms 8840 KB Output is correct
15 Correct 1 ms 2552 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 94 ms 6780 KB Output is correct
24 Correct 63 ms 4720 KB Output is correct
25 Correct 45 ms 4700 KB Output is correct
26 Correct 43 ms 4728 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 4 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 29 ms 8852 KB Output is correct
36 Correct 196 ms 8828 KB Output is correct
37 Correct 111 ms 8788 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 0 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 0 ms 2396 KB Output is correct
44 Correct 0 ms 2396 KB Output is correct
45 Correct 5 ms 2396 KB Output is correct
46 Correct 8 ms 2840 KB Output is correct
47 Correct 1 ms 2392 KB Output is correct
48 Correct 38 ms 4744 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 4 ms 2556 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 1 ms 2396 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 99 ms 6748 KB Output is correct
56 Correct 67 ms 4700 KB Output is correct
57 Correct 61 ms 4948 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2552 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 94 ms 6780 KB Output is correct
10 Correct 63 ms 4720 KB Output is correct
11 Correct 45 ms 4700 KB Output is correct
12 Correct 43 ms 4728 KB Output is correct
13 Correct 2 ms 2396 KB Output is correct
14 Correct 0 ms 2396 KB Output is correct
15 Correct 0 ms 2396 KB Output is correct
16 Correct 0 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 4 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 29 ms 8852 KB Output is correct
22 Correct 196 ms 8828 KB Output is correct
23 Correct 111 ms 8788 KB Output is correct
24 Correct 59 ms 4728 KB Output is correct
25 Correct 144 ms 6748 KB Output is correct
26 Correct 25 ms 4700 KB Output is correct
27 Correct 167 ms 8852 KB Output is correct
28 Correct 192 ms 8784 KB Output is correct
29 Correct 201 ms 8832 KB Output is correct
30 Correct 257 ms 8788 KB Output is correct
31 Correct 420 ms 8828 KB Output is correct
32 Correct 251 ms 8832 KB Output is correct
33 Correct 480 ms 8828 KB Output is correct
34 Correct 256 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2648 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8832 KB Output is correct
12 Correct 158 ms 8788 KB Output is correct
13 Correct 180 ms 8660 KB Output is correct
14 Correct 169 ms 8840 KB Output is correct
15 Correct 1 ms 2552 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 0 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 1 ms 2392 KB Output is correct
23 Correct 94 ms 6780 KB Output is correct
24 Correct 63 ms 4720 KB Output is correct
25 Correct 45 ms 4700 KB Output is correct
26 Correct 43 ms 4728 KB Output is correct
27 Correct 2 ms 2396 KB Output is correct
28 Correct 0 ms 2396 KB Output is correct
29 Correct 0 ms 2396 KB Output is correct
30 Correct 0 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 4 ms 2396 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 0 ms 2396 KB Output is correct
36 Correct 0 ms 2396 KB Output is correct
37 Correct 0 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 0 ms 2396 KB Output is correct
40 Correct 0 ms 2396 KB Output is correct
41 Correct 5 ms 2396 KB Output is correct
42 Correct 8 ms 2840 KB Output is correct
43 Correct 1 ms 2392 KB Output is correct
44 Correct 38 ms 4744 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2396 KB Output is correct
47 Correct 4 ms 2556 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 99 ms 6748 KB Output is correct
52 Correct 67 ms 4700 KB Output is correct
53 Correct 61 ms 4948 KB Output is correct
54 Correct 59 ms 4728 KB Output is correct
55 Correct 144 ms 6748 KB Output is correct
56 Correct 25 ms 4700 KB Output is correct
57 Correct 167 ms 8852 KB Output is correct
58 Correct 192 ms 8784 KB Output is correct
59 Correct 201 ms 8832 KB Output is correct
60 Correct 257 ms 8788 KB Output is correct
61 Correct 420 ms 8828 KB Output is correct
62 Correct 251 ms 8832 KB Output is correct
63 Correct 480 ms 8828 KB Output is correct
64 Correct 256 ms 8792 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 29 ms 8852 KB Output is correct
67 Correct 196 ms 8828 KB Output is correct
68 Correct 111 ms 8788 KB Output is correct
69 Correct 44 ms 4700 KB Output is correct
70 Correct 12 ms 2396 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 63 ms 4700 KB Output is correct
73 Correct 13 ms 2392 KB Output is correct
74 Correct 2 ms 2392 KB Output is correct
75 Correct 206 ms 8828 KB Output is correct
76 Correct 231 ms 8656 KB Output is correct
77 Correct 265 ms 8784 KB Output is correct
78 Correct 323 ms 8704 KB Output is correct
79 Correct 439 ms 8788 KB Output is correct
80 Correct 452 ms 9040 KB Output is correct
81 Correct 465 ms 8836 KB Output is correct
82 Correct 425 ms 8784 KB Output is correct