Submission #1083575

# Submission time Handle Problem Language Result Execution time Memory
1083575 2024-09-03T14:00:59 Z HuyAT Self Study (JOI22_ho_t2) C++14
62 / 100
69 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 = (long long)N * V,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 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 61 ms 11004 KB Output is correct
12 Correct 64 ms 10836 KB Output is correct
13 Correct 58 ms 8940 KB Output is correct
14 Correct 45 ms 8792 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 23 ms 6172 KB Output is correct
17 Correct 69 ms 11344 KB Output is correct
18 Correct 64 ms 10800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 23 ms 6172 KB Output is correct
3 Correct 69 ms 11344 KB Output is correct
4 Correct 64 ms 10800 KB Output is correct
5 Correct 0 ms 344 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 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 33 ms 5464 KB Output is correct
14 Correct 22 ms 3716 KB Output is correct
15 Correct 16 ms 2904 KB Output is correct
16 Correct 15 ms 2392 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 604 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 61 ms 11004 KB Output is correct
12 Correct 64 ms 10836 KB Output is correct
13 Correct 58 ms 8940 KB Output is correct
14 Correct 45 ms 8792 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 604 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 33 ms 5464 KB Output is correct
24 Correct 22 ms 3716 KB Output is correct
25 Correct 16 ms 2904 KB Output is correct
26 Correct 15 ms 2392 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 604 KB Output is correct
33 Correct 2 ms 604 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 23 ms 6172 KB Output is correct
36 Correct 69 ms 11344 KB Output is correct
37 Correct 64 ms 10800 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 464 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 584 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 476 KB Output is correct
48 Correct 13 ms 2144 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 36 ms 5492 KB Output is correct
56 Correct 24 ms 3420 KB Output is correct
57 Correct 18 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 33 ms 5464 KB Output is correct
10 Correct 22 ms 3716 KB Output is correct
11 Correct 16 ms 2904 KB Output is correct
12 Correct 15 ms 2392 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 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 23 ms 6172 KB Output is correct
22 Correct 69 ms 11344 KB Output is correct
23 Correct 64 ms 10800 KB Output is correct
24 Incorrect 13 ms 2052 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 61 ms 11004 KB Output is correct
12 Correct 64 ms 10836 KB Output is correct
13 Correct 58 ms 8940 KB Output is correct
14 Correct 45 ms 8792 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 604 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 33 ms 5464 KB Output is correct
24 Correct 22 ms 3716 KB Output is correct
25 Correct 16 ms 2904 KB Output is correct
26 Correct 15 ms 2392 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 604 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 464 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 584 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 476 KB Output is correct
44 Correct 13 ms 2144 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 36 ms 5492 KB Output is correct
52 Correct 24 ms 3420 KB Output is correct
53 Correct 18 ms 3164 KB Output is correct
54 Incorrect 13 ms 2052 KB Output isn't correct
55 Halted 0 ms 0 KB -