답안 #529433

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529433 2022-02-23T02:18:21 Z wiwiho Self Study (JOI22_ho_t2) C++14
100 / 100
363 ms 15044 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;
}

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 = 1LL << 60;
    while(l < r){
        ll mid = (l + r + 1) / 2;
        if(check(mid)) l = mid;
        else r = mid - 1;
    }


    cout << l << "\n";

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 232 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 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 4 ms 332 KB Output is correct
11 Correct 233 ms 9696 KB Output is correct
12 Correct 229 ms 9700 KB Output is correct
13 Correct 245 ms 9696 KB Output is correct
14 Correct 303 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 360 ms 9700 KB Output is correct
17 Correct 272 ms 9696 KB Output is correct
18 Correct 252 ms 9696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 360 ms 9700 KB Output is correct
3 Correct 272 ms 9696 KB Output is correct
4 Correct 252 ms 9696 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 224 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 117 ms 4940 KB Output is correct
14 Correct 79 ms 3404 KB Output is correct
15 Correct 58 ms 2636 KB Output is correct
16 Correct 59 ms 2184 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 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 6 ms 440 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 232 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 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 4 ms 332 KB Output is correct
11 Correct 233 ms 9696 KB Output is correct
12 Correct 229 ms 9700 KB Output is correct
13 Correct 245 ms 9696 KB Output is correct
14 Correct 303 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 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 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 117 ms 4940 KB Output is correct
24 Correct 79 ms 3404 KB Output is correct
25 Correct 58 ms 2636 KB Output is correct
26 Correct 59 ms 2184 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 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 6 ms 440 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 360 ms 9700 KB Output is correct
36 Correct 272 ms 9696 KB Output is correct
37 Correct 252 ms 9696 KB Output is correct
38 Correct 1 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 0 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 6 ms 460 KB Output is correct
46 Correct 9 ms 588 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 41 ms 1868 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 256 KB Output is correct
51 Correct 4 ms 460 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 0 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 118 ms 4960 KB Output is correct
56 Correct 84 ms 3404 KB Output is correct
57 Correct 98 ms 3416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 224 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 117 ms 4940 KB Output is correct
10 Correct 79 ms 3404 KB Output is correct
11 Correct 58 ms 2636 KB Output is correct
12 Correct 59 ms 2184 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 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 6 ms 440 KB Output is correct
19 Correct 5 ms 460 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 360 ms 9700 KB Output is correct
22 Correct 272 ms 9696 KB Output is correct
23 Correct 252 ms 9696 KB Output is correct
24 Correct 39 ms 1740 KB Output is correct
25 Correct 118 ms 5484 KB Output is correct
26 Correct 29 ms 1504 KB Output is correct
27 Correct 234 ms 12056 KB Output is correct
28 Correct 263 ms 14148 KB Output is correct
29 Correct 246 ms 12748 KB Output is correct
30 Correct 263 ms 11764 KB Output is correct
31 Correct 247 ms 12692 KB Output is correct
32 Correct 361 ms 10308 KB Output is correct
33 Correct 302 ms 11492 KB Output is correct
34 Correct 363 ms 10160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 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 232 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 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 4 ms 332 KB Output is correct
11 Correct 233 ms 9696 KB Output is correct
12 Correct 229 ms 9700 KB Output is correct
13 Correct 245 ms 9696 KB Output is correct
14 Correct 303 ms 9676 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 224 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 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 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 117 ms 4940 KB Output is correct
24 Correct 79 ms 3404 KB Output is correct
25 Correct 58 ms 2636 KB Output is correct
26 Correct 59 ms 2184 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 0 ms 204 KB Output is correct
31 Correct 0 ms 204 KB Output is correct
32 Correct 6 ms 440 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 0 ms 204 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 6 ms 460 KB Output is correct
42 Correct 9 ms 588 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 41 ms 1868 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 256 KB Output is correct
47 Correct 4 ms 460 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 118 ms 4960 KB Output is correct
52 Correct 84 ms 3404 KB Output is correct
53 Correct 98 ms 3416 KB Output is correct
54 Correct 39 ms 1740 KB Output is correct
55 Correct 118 ms 5484 KB Output is correct
56 Correct 29 ms 1504 KB Output is correct
57 Correct 234 ms 12056 KB Output is correct
58 Correct 263 ms 14148 KB Output is correct
59 Correct 246 ms 12748 KB Output is correct
60 Correct 263 ms 11764 KB Output is correct
61 Correct 247 ms 12692 KB Output is correct
62 Correct 361 ms 10308 KB Output is correct
63 Correct 302 ms 11492 KB Output is correct
64 Correct 363 ms 10160 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 360 ms 9700 KB Output is correct
67 Correct 272 ms 9696 KB Output is correct
68 Correct 252 ms 9696 KB Output is correct
69 Correct 28 ms 1476 KB Output is correct
70 Correct 7 ms 588 KB Output is correct
71 Correct 1 ms 204 KB Output is correct
72 Correct 37 ms 1916 KB Output is correct
73 Correct 9 ms 704 KB Output is correct
74 Correct 2 ms 332 KB Output is correct
75 Correct 252 ms 11980 KB Output is correct
76 Correct 267 ms 13484 KB Output is correct
77 Correct 252 ms 14064 KB Output is correct
78 Correct 286 ms 12572 KB Output is correct
79 Correct 269 ms 14352 KB Output is correct
80 Correct 302 ms 15044 KB Output is correct
81 Correct 282 ms 13108 KB Output is correct
82 Correct 317 ms 12548 KB Output is correct