답안 #923743

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923743 2024-02-07T17:16:50 Z shahd_abbara Self Study (JOI22_ho_t2) C++17
100 / 100
393 ms 9044 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 = 1e9;
    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 1 ms 2396 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 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 120 ms 8920 KB Output is correct
12 Correct 119 ms 8912 KB Output is correct
13 Correct 120 ms 8828 KB Output is correct
14 Correct 116 ms 8828 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 25 ms 8640 KB Output is correct
17 Correct 134 ms 9024 KB Output is correct
18 Correct 115 ms 8788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 25 ms 8640 KB Output is correct
3 Correct 134 ms 9024 KB Output is correct
4 Correct 115 ms 8788 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 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 1 ms 2396 KB Output is correct
11 Correct 0 ms 2464 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 59 ms 6780 KB Output is correct
14 Correct 40 ms 4696 KB Output is correct
15 Correct 29 ms 4700 KB Output is correct
16 Correct 26 ms 4696 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2648 KB Output is correct
21 Correct 0 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 1 ms 2396 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 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 120 ms 8920 KB Output is correct
12 Correct 119 ms 8912 KB Output is correct
13 Correct 120 ms 8828 KB Output is correct
14 Correct 116 ms 8828 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 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 1 ms 2396 KB Output is correct
21 Correct 0 ms 2464 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 59 ms 6780 KB Output is correct
24 Correct 40 ms 4696 KB Output is correct
25 Correct 29 ms 4700 KB Output is correct
26 Correct 26 ms 4696 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2648 KB Output is correct
31 Correct 0 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 25 ms 8640 KB Output is correct
36 Correct 134 ms 9024 KB Output is correct
37 Correct 115 ms 8788 KB Output is correct
38 Correct 0 ms 2392 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 1 ms 2392 KB Output is correct
43 Correct 0 ms 2512 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 3 ms 2396 KB Output is correct
46 Correct 4 ms 2396 KB Output is correct
47 Correct 1 ms 2392 KB Output is correct
48 Correct 22 ms 4700 KB Output is correct
49 Correct 1 ms 2396 KB Output is correct
50 Correct 1 ms 2392 KB Output is correct
51 Correct 3 ms 2392 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 61 ms 6780 KB Output is correct
56 Correct 43 ms 4696 KB Output is correct
57 Correct 45 ms 4944 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 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 1 ms 2396 KB Output is correct
7 Correct 0 ms 2464 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 59 ms 6780 KB Output is correct
10 Correct 40 ms 4696 KB Output is correct
11 Correct 29 ms 4700 KB Output is correct
12 Correct 26 ms 4696 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2648 KB Output is correct
17 Correct 0 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 25 ms 8640 KB Output is correct
22 Correct 134 ms 9024 KB Output is correct
23 Correct 115 ms 8788 KB Output is correct
24 Correct 47 ms 4696 KB Output is correct
25 Correct 108 ms 6748 KB Output is correct
26 Correct 18 ms 4700 KB Output is correct
27 Correct 112 ms 8836 KB Output is correct
28 Correct 122 ms 8836 KB Output is correct
29 Correct 124 ms 8832 KB Output is correct
30 Correct 175 ms 8824 KB Output is correct
31 Correct 335 ms 9044 KB Output is correct
32 Correct 151 ms 8828 KB Output is correct
33 Correct 393 ms 8836 KB Output is correct
34 Correct 168 ms 8792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 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 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 120 ms 8920 KB Output is correct
12 Correct 119 ms 8912 KB Output is correct
13 Correct 120 ms 8828 KB Output is correct
14 Correct 116 ms 8828 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 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 1 ms 2396 KB Output is correct
21 Correct 0 ms 2464 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 59 ms 6780 KB Output is correct
24 Correct 40 ms 4696 KB Output is correct
25 Correct 29 ms 4700 KB Output is correct
26 Correct 26 ms 4696 KB Output is correct
27 Correct 1 ms 2396 KB Output is correct
28 Correct 1 ms 2396 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2648 KB Output is correct
31 Correct 0 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 0 ms 2392 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2396 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 1 ms 2392 KB Output is correct
39 Correct 0 ms 2512 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 3 ms 2396 KB Output is correct
42 Correct 4 ms 2396 KB Output is correct
43 Correct 1 ms 2392 KB Output is correct
44 Correct 22 ms 4700 KB Output is correct
45 Correct 1 ms 2396 KB Output is correct
46 Correct 1 ms 2392 KB Output is correct
47 Correct 3 ms 2392 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 61 ms 6780 KB Output is correct
52 Correct 43 ms 4696 KB Output is correct
53 Correct 45 ms 4944 KB Output is correct
54 Correct 47 ms 4696 KB Output is correct
55 Correct 108 ms 6748 KB Output is correct
56 Correct 18 ms 4700 KB Output is correct
57 Correct 112 ms 8836 KB Output is correct
58 Correct 122 ms 8836 KB Output is correct
59 Correct 124 ms 8832 KB Output is correct
60 Correct 175 ms 8824 KB Output is correct
61 Correct 335 ms 9044 KB Output is correct
62 Correct 151 ms 8828 KB Output is correct
63 Correct 393 ms 8836 KB Output is correct
64 Correct 168 ms 8792 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 25 ms 8640 KB Output is correct
67 Correct 134 ms 9024 KB Output is correct
68 Correct 115 ms 8788 KB Output is correct
69 Correct 34 ms 4952 KB Output is correct
70 Correct 10 ms 2396 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 52 ms 4700 KB Output is correct
73 Correct 11 ms 2392 KB Output is correct
74 Correct 1 ms 2396 KB Output is correct
75 Correct 127 ms 8832 KB Output is correct
76 Correct 154 ms 8828 KB Output is correct
77 Correct 176 ms 8824 KB Output is correct
78 Correct 244 ms 9044 KB Output is correct
79 Correct 347 ms 8784 KB Output is correct
80 Correct 372 ms 8828 KB Output is correct
81 Correct 383 ms 8784 KB Output is correct
82 Correct 340 ms 8840 KB Output is correct