답안 #923736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923736 2024-02-07T17:02:32 Z shahd_abbara Self Study (JOI22_ho_t2) C++17
91 / 100
1000 ms 15276 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 <= ll(m * n))
        return 1;
    return 0;
}
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 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 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 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8784 KB Output is correct
12 Correct 154 ms 8788 KB Output is correct
13 Correct 192 ms 8844 KB Output is correct
14 Correct 210 ms 8832 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 33 ms 10008 KB Output is correct
17 Correct 208 ms 15212 KB Output is correct
18 Correct 112 ms 14736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 33 ms 10008 KB Output is correct
3 Correct 208 ms 15212 KB Output is correct
4 Correct 112 ms 14736 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2688 KB Output is correct
8 Correct 1 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 2396 KB Output is correct
13 Correct 94 ms 6800 KB Output is correct
14 Correct 62 ms 4724 KB Output is correct
15 Correct 45 ms 4724 KB Output is correct
16 Correct 40 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 2396 KB Output is correct
21 Correct 0 ms 2396 KB Output is correct
22 Correct 2 ms 2396 KB Output is correct
23 Correct 5 ms 2652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 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 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8784 KB Output is correct
12 Correct 154 ms 8788 KB Output is correct
13 Correct 192 ms 8844 KB Output is correct
14 Correct 210 ms 8832 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2688 KB Output is correct
18 Correct 1 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 2396 KB Output is correct
23 Correct 94 ms 6800 KB Output is correct
24 Correct 62 ms 4724 KB Output is correct
25 Correct 45 ms 4724 KB Output is correct
26 Correct 40 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 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 5 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 33 ms 10008 KB Output is correct
36 Correct 208 ms 15212 KB Output is correct
37 Correct 112 ms 14736 KB Output is correct
38 Correct 1 ms 2396 KB Output is correct
39 Correct 1 ms 2396 KB Output is correct
40 Correct 1 ms 2392 KB Output is correct
41 Correct 1 ms 2396 KB Output is correct
42 Correct 0 ms 2396 KB Output is correct
43 Correct 1 ms 2524 KB Output is correct
44 Correct 1 ms 2396 KB Output is correct
45 Correct 4 ms 2652 KB Output is correct
46 Correct 7 ms 2652 KB Output is correct
47 Correct 2 ms 2396 KB Output is correct
48 Correct 36 ms 5716 KB Output is correct
49 Correct 1 ms 2392 KB Output is correct
50 Correct 2 ms 2396 KB Output is correct
51 Correct 5 ms 2396 KB Output is correct
52 Correct 1 ms 2396 KB Output is correct
53 Correct 2 ms 2392 KB Output is correct
54 Correct 1 ms 2396 KB Output is correct
55 Correct 102 ms 9600 KB Output is correct
56 Correct 70 ms 5984 KB Output is correct
57 Correct 73 ms 5976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 1 ms 2688 KB Output is correct
4 Correct 1 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 2396 KB Output is correct
9 Correct 94 ms 6800 KB Output is correct
10 Correct 62 ms 4724 KB Output is correct
11 Correct 45 ms 4724 KB Output is correct
12 Correct 40 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 2396 KB Output is correct
17 Correct 0 ms 2396 KB Output is correct
18 Correct 2 ms 2396 KB Output is correct
19 Correct 5 ms 2652 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 33 ms 10008 KB Output is correct
22 Correct 208 ms 15212 KB Output is correct
23 Correct 112 ms 14736 KB Output is correct
24 Correct 59 ms 5620 KB Output is correct
25 Correct 145 ms 9372 KB Output is correct
26 Correct 26 ms 5212 KB Output is correct
27 Correct 167 ms 14628 KB Output is correct
28 Correct 197 ms 14784 KB Output is correct
29 Correct 208 ms 14416 KB Output is correct
30 Correct 255 ms 14416 KB Output is correct
31 Correct 416 ms 14416 KB Output is correct
32 Correct 247 ms 9816 KB Output is correct
33 Correct 479 ms 15276 KB Output is correct
34 Correct 251 ms 9808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 0 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 2 ms 2396 KB Output is correct
10 Correct 3 ms 2396 KB Output is correct
11 Correct 167 ms 8784 KB Output is correct
12 Correct 154 ms 8788 KB Output is correct
13 Correct 192 ms 8844 KB Output is correct
14 Correct 210 ms 8832 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 0 ms 2392 KB Output is correct
17 Correct 1 ms 2688 KB Output is correct
18 Correct 1 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 2396 KB Output is correct
23 Correct 94 ms 6800 KB Output is correct
24 Correct 62 ms 4724 KB Output is correct
25 Correct 45 ms 4724 KB Output is correct
26 Correct 40 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 2396 KB Output is correct
31 Correct 0 ms 2396 KB Output is correct
32 Correct 2 ms 2396 KB Output is correct
33 Correct 5 ms 2652 KB Output is correct
34 Correct 1 ms 2396 KB Output is correct
35 Correct 1 ms 2396 KB Output is correct
36 Correct 1 ms 2392 KB Output is correct
37 Correct 1 ms 2396 KB Output is correct
38 Correct 0 ms 2396 KB Output is correct
39 Correct 1 ms 2524 KB Output is correct
40 Correct 1 ms 2396 KB Output is correct
41 Correct 4 ms 2652 KB Output is correct
42 Correct 7 ms 2652 KB Output is correct
43 Correct 2 ms 2396 KB Output is correct
44 Correct 36 ms 5716 KB Output is correct
45 Correct 1 ms 2392 KB Output is correct
46 Correct 2 ms 2396 KB Output is correct
47 Correct 5 ms 2396 KB Output is correct
48 Correct 1 ms 2396 KB Output is correct
49 Correct 2 ms 2392 KB Output is correct
50 Correct 1 ms 2396 KB Output is correct
51 Correct 102 ms 9600 KB Output is correct
52 Correct 70 ms 5984 KB Output is correct
53 Correct 73 ms 5976 KB Output is correct
54 Correct 59 ms 5620 KB Output is correct
55 Correct 145 ms 9372 KB Output is correct
56 Correct 26 ms 5212 KB Output is correct
57 Correct 167 ms 14628 KB Output is correct
58 Correct 197 ms 14784 KB Output is correct
59 Correct 208 ms 14416 KB Output is correct
60 Correct 255 ms 14416 KB Output is correct
61 Correct 416 ms 14416 KB Output is correct
62 Correct 247 ms 9816 KB Output is correct
63 Correct 479 ms 15276 KB Output is correct
64 Correct 251 ms 9808 KB Output is correct
65 Correct 1 ms 2396 KB Output is correct
66 Correct 33 ms 10008 KB Output is correct
67 Correct 208 ms 15212 KB Output is correct
68 Correct 112 ms 14736 KB Output is correct
69 Correct 43 ms 5212 KB Output is correct
70 Correct 12 ms 2652 KB Output is correct
71 Correct 1 ms 2396 KB Output is correct
72 Correct 64 ms 5564 KB Output is correct
73 Correct 13 ms 2900 KB Output is correct
74 Correct 2 ms 2396 KB Output is correct
75 Correct 211 ms 14624 KB Output is correct
76 Correct 232 ms 14628 KB Output is correct
77 Correct 255 ms 14628 KB Output is correct
78 Correct 327 ms 14624 KB Output is correct
79 Correct 429 ms 14436 KB Output is correct
80 Correct 457 ms 14720 KB Output is correct
81 Correct 467 ms 12880 KB Output is correct
82 Execution timed out 1052 ms 12636 KB Time limit exceeded
83 Halted 0 ms 0 KB -