Submission #1083576

# Submission time Handle Problem Language Result Execution time Memory
1083576 2024-09-03T14:04:36 Z HuyAT Self Study (JOI22_ho_t2) C++14
100 / 100
108 ms 11344 KB
#include<bits/stdc++.h>
#define newl '\n'

const int N = 3e5 + 10;
const int V = 1e9 + 10;
const long long INF = 1e18;
const long long M = 1e9 + 7;

long long a[N + 1],b[N + 1],n,m;

void readData(){
    std::cin >> n >> m;
    for(int i = 1;i <= n;++i){
        std::cin >> a[i];
    }
    for(int i = 1;i <= n;++i){
        std::cin >> b[i];
        a[i] = std::max(a[i],b[i]);
    }
}
bool f(long long mid){
    long long s = 0;
    for(int i = 1;i <= n;++i){
        long long t = std::min(m,((mid - 1)) / a[i] + 1);
        s += t;
        if(a[i] * t < mid){
            s += ((mid - a[i] * t - 1) / b[i] + 1);
        }
        if(s > m * n){
            return false;
        }
    }
    return true;
}
long long solve(){
    long long lo = 0,hi = 1e18,ans = 0;
    while(lo <= hi){
        long long mid = (lo + hi) / 2;
        if(f(mid)){
            ans = mid;
            lo = mid + 1;
        }else{
            hi = mid - 1;
        }
    }
    return ans;
}
int main(){
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);std::cout.tie(nullptr);
    readData();
    std::cout << solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 75 ms 10836 KB Output is correct
12 Correct 64 ms 10832 KB Output is correct
13 Correct 57 ms 8784 KB Output is correct
14 Correct 47 ms 8784 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 25 ms 6228 KB Output is correct
17 Correct 69 ms 11344 KB Output is correct
18 Correct 64 ms 10832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 25 ms 6228 KB Output is correct
3 Correct 69 ms 11344 KB Output is correct
4 Correct 64 ms 10832 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 38 ms 5544 KB Output is correct
14 Correct 23 ms 3920 KB Output is correct
15 Correct 16 ms 2944 KB Output is correct
16 Correct 17 ms 2420 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 75 ms 10836 KB Output is correct
12 Correct 64 ms 10832 KB Output is correct
13 Correct 57 ms 8784 KB Output is correct
14 Correct 47 ms 8784 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 38 ms 5544 KB Output is correct
24 Correct 23 ms 3920 KB Output is correct
25 Correct 16 ms 2944 KB Output is correct
26 Correct 17 ms 2420 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 25 ms 6228 KB Output is correct
36 Correct 69 ms 11344 KB Output is correct
37 Correct 64 ms 10832 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 15 ms 2020 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 620 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 36 ms 5544 KB Output is correct
56 Correct 23 ms 3160 KB Output is correct
57 Correct 16 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 38 ms 5544 KB Output is correct
10 Correct 23 ms 3920 KB Output is correct
11 Correct 16 ms 2944 KB Output is correct
12 Correct 17 ms 2420 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 25 ms 6228 KB Output is correct
22 Correct 69 ms 11344 KB Output is correct
23 Correct 64 ms 10832 KB Output is correct
24 Correct 15 ms 2092 KB Output is correct
25 Correct 42 ms 4920 KB Output is correct
26 Correct 11 ms 1372 KB Output is correct
27 Correct 64 ms 10676 KB Output is correct
28 Correct 73 ms 10920 KB Output is correct
29 Correct 75 ms 10836 KB Output is correct
30 Correct 85 ms 10828 KB Output is correct
31 Correct 92 ms 10680 KB Output is correct
32 Correct 54 ms 6236 KB Output is correct
33 Correct 88 ms 11344 KB Output is correct
34 Correct 63 ms 6236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 75 ms 10836 KB Output is correct
12 Correct 64 ms 10832 KB Output is correct
13 Correct 57 ms 8784 KB Output is correct
14 Correct 47 ms 8784 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 38 ms 5544 KB Output is correct
24 Correct 23 ms 3920 KB Output is correct
25 Correct 16 ms 2944 KB Output is correct
26 Correct 17 ms 2420 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 2 ms 604 KB Output is correct
42 Correct 2 ms 604 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 15 ms 2020 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 620 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 36 ms 5544 KB Output is correct
52 Correct 23 ms 3160 KB Output is correct
53 Correct 16 ms 3160 KB Output is correct
54 Correct 15 ms 2092 KB Output is correct
55 Correct 42 ms 4920 KB Output is correct
56 Correct 11 ms 1372 KB Output is correct
57 Correct 64 ms 10676 KB Output is correct
58 Correct 73 ms 10920 KB Output is correct
59 Correct 75 ms 10836 KB Output is correct
60 Correct 85 ms 10828 KB Output is correct
61 Correct 92 ms 10680 KB Output is correct
62 Correct 54 ms 6236 KB Output is correct
63 Correct 88 ms 11344 KB Output is correct
64 Correct 63 ms 6236 KB Output is correct
65 Correct 1 ms 344 KB Output is correct
66 Correct 25 ms 6228 KB Output is correct
67 Correct 69 ms 11344 KB Output is correct
68 Correct 64 ms 10832 KB Output is correct
69 Correct 11 ms 1372 KB Output is correct
70 Correct 3 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 15 ms 1984 KB Output is correct
73 Correct 3 ms 604 KB Output is correct
74 Correct 1 ms 348 KB Output is correct
75 Correct 75 ms 10920 KB Output is correct
76 Correct 84 ms 10804 KB Output is correct
77 Correct 94 ms 10832 KB Output is correct
78 Correct 102 ms 10720 KB Output is correct
79 Correct 108 ms 10836 KB Output is correct
80 Correct 104 ms 10836 KB Output is correct
81 Correct 73 ms 8796 KB Output is correct
82 Correct 77 ms 8788 KB Output is correct