답안 #798366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
798366 2023-07-30T16:04:42 Z n3rm1n Self Study (JOI22_ho_t2) C++17
62 / 100
202 ms 16092 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const long long  MAXN = 3e5 + 10;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
long long  n, m;
long long  a[MAXN], b[MAXN];
void read()
{
    cin >> n >> m;
    for (long long  i = 1; i <= n; ++ i)
        cin >> a[i];
    for (long long  i = 1; i <= n; ++ i)
        cin >> b[i];
}
long long  useda[MAXN], needb[MAXN];
bool check(long long  x)
{
    memset(useda, 0, sizeof(useda));
    memset(needb, 0, sizeof(needb));
    long long  suma = 0, sumb = 0;
    for (long long  i = 1; i <= n; ++ i)
    {
        if(a[i] > b[i])
        {
            long long  times = x / a[i];
            if(x % a[i] != 0)times ++;
            times = min(m, times);
            useda[i] = times;
            long long  ost = max(1LL * 0, x - times * a[i]);
            needb[i] = ost / b[i];
            if(ost % b[i] != 0)needb[i] ++;
        }
        else
        {
            needb[i] = x / b[i];
            if(x % b[i] != 0)needb[i] ++;
        }
        suma += useda[i];
        sumb += needb[i];
        if(suma + sumb > n * m)return false;
    }

    return (sumb <= n * m - suma);
}
void solve()
{
    long long  l = 0, r = 1e17, mid, ans = 0;
    while(l <= r)
    {
        mid = (l + r)/2;
        if(check(mid))
        {
            ans = mid;
            l = mid + 1LL * 1;
        }
        else r = mid - 1LL * 1;
    }
    cout << ans << endl;
}
int main()
{
    speed();

    read();
    solve();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4936 KB Output is correct
2 Correct 7 ms 4932 KB Output is correct
3 Correct 6 ms 5040 KB Output is correct
4 Correct 6 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 6 ms 4948 KB Output is correct
7 Correct 6 ms 4948 KB Output is correct
8 Correct 6 ms 4948 KB Output is correct
9 Correct 6 ms 4936 KB Output is correct
10 Correct 8 ms 5076 KB Output is correct
11 Correct 100 ms 9924 KB Output is correct
12 Correct 101 ms 9828 KB Output is correct
13 Correct 79 ms 9928 KB Output is correct
14 Correct 72 ms 9928 KB Output is correct
15 Correct 6 ms 4948 KB Output is correct
16 Correct 34 ms 10836 KB Output is correct
17 Correct 90 ms 16076 KB Output is correct
18 Correct 99 ms 15616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4948 KB Output is correct
2 Correct 34 ms 10836 KB Output is correct
3 Correct 90 ms 16076 KB Output is correct
4 Correct 99 ms 15616 KB Output is correct
5 Correct 8 ms 4932 KB Output is correct
6 Correct 6 ms 4948 KB Output is correct
7 Correct 7 ms 5032 KB Output is correct
8 Correct 8 ms 4948 KB Output is correct
9 Correct 7 ms 5036 KB Output is correct
10 Correct 8 ms 5036 KB Output is correct
11 Correct 6 ms 4996 KB Output is correct
12 Correct 7 ms 4948 KB Output is correct
13 Correct 49 ms 7616 KB Output is correct
14 Correct 36 ms 6732 KB Output is correct
15 Correct 28 ms 6404 KB Output is correct
16 Correct 29 ms 6220 KB Output is correct
17 Correct 7 ms 4948 KB Output is correct
18 Correct 6 ms 4948 KB Output is correct
19 Correct 6 ms 5032 KB Output is correct
20 Correct 6 ms 4948 KB Output is correct
21 Correct 6 ms 4944 KB Output is correct
22 Correct 8 ms 5076 KB Output is correct
23 Correct 8 ms 5216 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4936 KB Output is correct
2 Correct 7 ms 4932 KB Output is correct
3 Correct 6 ms 5040 KB Output is correct
4 Correct 6 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 6 ms 4948 KB Output is correct
7 Correct 6 ms 4948 KB Output is correct
8 Correct 6 ms 4948 KB Output is correct
9 Correct 6 ms 4936 KB Output is correct
10 Correct 8 ms 5076 KB Output is correct
11 Correct 100 ms 9924 KB Output is correct
12 Correct 101 ms 9828 KB Output is correct
13 Correct 79 ms 9928 KB Output is correct
14 Correct 72 ms 9928 KB Output is correct
15 Correct 8 ms 4932 KB Output is correct
16 Correct 6 ms 4948 KB Output is correct
17 Correct 7 ms 5032 KB Output is correct
18 Correct 8 ms 4948 KB Output is correct
19 Correct 7 ms 5036 KB Output is correct
20 Correct 8 ms 5036 KB Output is correct
21 Correct 6 ms 4996 KB Output is correct
22 Correct 7 ms 4948 KB Output is correct
23 Correct 49 ms 7616 KB Output is correct
24 Correct 36 ms 6732 KB Output is correct
25 Correct 28 ms 6404 KB Output is correct
26 Correct 29 ms 6220 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 6 ms 4948 KB Output is correct
29 Correct 6 ms 5032 KB Output is correct
30 Correct 6 ms 4948 KB Output is correct
31 Correct 6 ms 4944 KB Output is correct
32 Correct 8 ms 5076 KB Output is correct
33 Correct 8 ms 5216 KB Output is correct
34 Correct 6 ms 4948 KB Output is correct
35 Correct 34 ms 10836 KB Output is correct
36 Correct 90 ms 16076 KB Output is correct
37 Correct 99 ms 15616 KB Output is correct
38 Correct 7 ms 4948 KB Output is correct
39 Correct 7 ms 4948 KB Output is correct
40 Correct 8 ms 4948 KB Output is correct
41 Correct 7 ms 4948 KB Output is correct
42 Correct 6 ms 5036 KB Output is correct
43 Correct 6 ms 4948 KB Output is correct
44 Correct 6 ms 4948 KB Output is correct
45 Correct 8 ms 5208 KB Output is correct
46 Correct 9 ms 5284 KB Output is correct
47 Correct 7 ms 4968 KB Output is correct
48 Correct 24 ms 6740 KB Output is correct
49 Correct 6 ms 4948 KB Output is correct
50 Correct 6 ms 4948 KB Output is correct
51 Correct 8 ms 5076 KB Output is correct
52 Correct 6 ms 4948 KB Output is correct
53 Correct 6 ms 4948 KB Output is correct
54 Correct 6 ms 4940 KB Output is correct
55 Correct 59 ms 10216 KB Output is correct
56 Correct 33 ms 7764 KB Output is correct
57 Correct 27 ms 7744 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 4932 KB Output is correct
2 Correct 6 ms 4948 KB Output is correct
3 Correct 7 ms 5032 KB Output is correct
4 Correct 8 ms 4948 KB Output is correct
5 Correct 7 ms 5036 KB Output is correct
6 Correct 8 ms 5036 KB Output is correct
7 Correct 6 ms 4996 KB Output is correct
8 Correct 7 ms 4948 KB Output is correct
9 Correct 49 ms 7616 KB Output is correct
10 Correct 36 ms 6732 KB Output is correct
11 Correct 28 ms 6404 KB Output is correct
12 Correct 29 ms 6220 KB Output is correct
13 Correct 7 ms 4948 KB Output is correct
14 Correct 6 ms 4948 KB Output is correct
15 Correct 6 ms 5032 KB Output is correct
16 Correct 6 ms 4948 KB Output is correct
17 Correct 6 ms 4944 KB Output is correct
18 Correct 8 ms 5076 KB Output is correct
19 Correct 8 ms 5216 KB Output is correct
20 Correct 6 ms 4948 KB Output is correct
21 Correct 34 ms 10836 KB Output is correct
22 Correct 90 ms 16076 KB Output is correct
23 Correct 99 ms 15616 KB Output is correct
24 Correct 33 ms 6632 KB Output is correct
25 Correct 71 ms 9592 KB Output is correct
26 Correct 17 ms 6136 KB Output is correct
27 Correct 89 ms 15384 KB Output is correct
28 Correct 96 ms 15436 KB Output is correct
29 Correct 97 ms 15504 KB Output is correct
30 Correct 121 ms 15584 KB Output is correct
31 Correct 189 ms 15452 KB Output is correct
32 Correct 115 ms 10868 KB Output is correct
33 Incorrect 202 ms 16092 KB Output isn't correct
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4936 KB Output is correct
2 Correct 7 ms 4932 KB Output is correct
3 Correct 6 ms 5040 KB Output is correct
4 Correct 6 ms 4948 KB Output is correct
5 Correct 6 ms 4948 KB Output is correct
6 Correct 6 ms 4948 KB Output is correct
7 Correct 6 ms 4948 KB Output is correct
8 Correct 6 ms 4948 KB Output is correct
9 Correct 6 ms 4936 KB Output is correct
10 Correct 8 ms 5076 KB Output is correct
11 Correct 100 ms 9924 KB Output is correct
12 Correct 101 ms 9828 KB Output is correct
13 Correct 79 ms 9928 KB Output is correct
14 Correct 72 ms 9928 KB Output is correct
15 Correct 8 ms 4932 KB Output is correct
16 Correct 6 ms 4948 KB Output is correct
17 Correct 7 ms 5032 KB Output is correct
18 Correct 8 ms 4948 KB Output is correct
19 Correct 7 ms 5036 KB Output is correct
20 Correct 8 ms 5036 KB Output is correct
21 Correct 6 ms 4996 KB Output is correct
22 Correct 7 ms 4948 KB Output is correct
23 Correct 49 ms 7616 KB Output is correct
24 Correct 36 ms 6732 KB Output is correct
25 Correct 28 ms 6404 KB Output is correct
26 Correct 29 ms 6220 KB Output is correct
27 Correct 7 ms 4948 KB Output is correct
28 Correct 6 ms 4948 KB Output is correct
29 Correct 6 ms 5032 KB Output is correct
30 Correct 6 ms 4948 KB Output is correct
31 Correct 6 ms 4944 KB Output is correct
32 Correct 8 ms 5076 KB Output is correct
33 Correct 8 ms 5216 KB Output is correct
34 Correct 7 ms 4948 KB Output is correct
35 Correct 7 ms 4948 KB Output is correct
36 Correct 8 ms 4948 KB Output is correct
37 Correct 7 ms 4948 KB Output is correct
38 Correct 6 ms 5036 KB Output is correct
39 Correct 6 ms 4948 KB Output is correct
40 Correct 6 ms 4948 KB Output is correct
41 Correct 8 ms 5208 KB Output is correct
42 Correct 9 ms 5284 KB Output is correct
43 Correct 7 ms 4968 KB Output is correct
44 Correct 24 ms 6740 KB Output is correct
45 Correct 6 ms 4948 KB Output is correct
46 Correct 6 ms 4948 KB Output is correct
47 Correct 8 ms 5076 KB Output is correct
48 Correct 6 ms 4948 KB Output is correct
49 Correct 6 ms 4948 KB Output is correct
50 Correct 6 ms 4940 KB Output is correct
51 Correct 59 ms 10216 KB Output is correct
52 Correct 33 ms 7764 KB Output is correct
53 Correct 27 ms 7744 KB Output is correct
54 Correct 33 ms 6632 KB Output is correct
55 Correct 71 ms 9592 KB Output is correct
56 Correct 17 ms 6136 KB Output is correct
57 Correct 89 ms 15384 KB Output is correct
58 Correct 96 ms 15436 KB Output is correct
59 Correct 97 ms 15504 KB Output is correct
60 Correct 121 ms 15584 KB Output is correct
61 Correct 189 ms 15452 KB Output is correct
62 Correct 115 ms 10868 KB Output is correct
63 Incorrect 202 ms 16092 KB Output isn't correct
64 Halted 0 ms 0 KB -