Submission #529432

# Submission time Handle Problem Language Result Execution time Memory
529432 2022-02-23T02:15:00 Z wiwiho Self Study (JOI22_ho_t2) C++14
62 / 100
277 ms 9708 KB
#include <bits/stdc++.h>

#define iter(a) a.begin(), a.end()

using namespace std;

typedef __int128 ll;

ll iceil(ll a, ll b){
    return (a + b - 1) / b;
}

int n;
ll m;
vector<ll> a, b;

ll tans;

istream& operator>>(istream& i, __int128& a){
    long long t;
    i >> t;
    a = t;
    return i;
}

ostream& operator<<(ostream& o, __int128 a){
    long long t = a;
    return o << t;
}

bool check(ll mn){
    ll cnt = 0;
    for(int i = 1; i <= n; i++){
        ll need = iceil(mn, a[i]);
        if(need <= m){
            cnt += m - need;
            continue;
        }
        ll tmp = mn - m * a[i];
        cnt -= iceil(tmp, b[i]);
    }

    return cnt >= 0;
}

mt19937 rnd(123123);
uniform_int_distribution<int> ud(48763, 123456);

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> n >> m;
    a.resize(n + 1);
    b.resize(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++) cin >> b[i];
    
    for(int i = 1; i <= n; i++) a[i] = max(a[i], b[i]);

    ll l = 0, r = 1e15;
    while(l < r){
        ll mid = (l + r + 1) / 2;
        if(check(mid)) l = mid;
        else r = mid - 1;
    }


    cout << l << "\n";

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 184 ms 9700 KB Output is correct
12 Correct 176 ms 9676 KB Output is correct
13 Correct 193 ms 9708 KB Output is correct
14 Correct 250 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 277 ms 9704 KB Output is correct
17 Correct 240 ms 9676 KB Output is correct
18 Correct 176 ms 9700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 277 ms 9704 KB Output is correct
3 Correct 240 ms 9676 KB Output is correct
4 Correct 176 ms 9700 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 112 ms 5000 KB Output is correct
14 Correct 60 ms 3440 KB Output is correct
15 Correct 45 ms 2636 KB Output is correct
16 Correct 38 ms 2124 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 5 ms 460 KB Output is correct
23 Correct 4 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 184 ms 9700 KB Output is correct
12 Correct 176 ms 9676 KB Output is correct
13 Correct 193 ms 9708 KB Output is correct
14 Correct 250 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 112 ms 5000 KB Output is correct
24 Correct 60 ms 3440 KB Output is correct
25 Correct 45 ms 2636 KB Output is correct
26 Correct 38 ms 2124 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 5 ms 460 KB Output is correct
33 Correct 4 ms 440 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 277 ms 9704 KB Output is correct
36 Correct 240 ms 9676 KB Output is correct
37 Correct 176 ms 9700 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 0 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 4 ms 432 KB Output is correct
46 Correct 7 ms 648 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 34 ms 2500 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 4 ms 460 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 96 ms 6668 KB Output is correct
56 Correct 66 ms 4028 KB Output is correct
57 Correct 87 ms 4116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 112 ms 5000 KB Output is correct
10 Correct 60 ms 3440 KB Output is correct
11 Correct 45 ms 2636 KB Output is correct
12 Correct 38 ms 2124 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 5 ms 460 KB Output is correct
19 Correct 4 ms 440 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 277 ms 9704 KB Output is correct
22 Correct 240 ms 9676 KB Output is correct
23 Correct 176 ms 9700 KB Output is correct
24 Incorrect 31 ms 2116 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 184 ms 9700 KB Output is correct
12 Correct 176 ms 9676 KB Output is correct
13 Correct 193 ms 9708 KB Output is correct
14 Correct 250 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 112 ms 5000 KB Output is correct
24 Correct 60 ms 3440 KB Output is correct
25 Correct 45 ms 2636 KB Output is correct
26 Correct 38 ms 2124 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 5 ms 460 KB Output is correct
33 Correct 4 ms 440 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 1 ms 204 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 4 ms 432 KB Output is correct
42 Correct 7 ms 648 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 34 ms 2500 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 4 ms 460 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 96 ms 6668 KB Output is correct
52 Correct 66 ms 4028 KB Output is correct
53 Correct 87 ms 4116 KB Output is correct
54 Incorrect 31 ms 2116 KB Output isn't correct
55 Halted 0 ms 0 KB -