답안 #703653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703653 2023-02-28T03:20:19 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
434 ms 7520 KB
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pii pair<long long,int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define STL(i, x) for(auto &i:x) cout << i << " "; cout << "\n";
using namespace std;

long long a[300050], b[300050], c[300050];

/*ostream& operator<<(ostream &os, pii XXX){
    cout << "[" << XXX.ff << ", " << XXX.ss << "]";
}*/
void db(){
    cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
    cout << XXX;  db(YYY...);
}

__int128 min(__int128 XXX, __int128 YYY){
    return (XXX > YYY) ? (YYY) : (XXX);
}

int main(){
    long long n, m, all;
    cin >> n >> m;
    all = n * m;
    loop(i,0,n) cin >> a[i];
    loop(i,0,n) cin >> b[i];
    loop(i,0,n) c[i] = max(a[i], b[i]);
    long long Tr = 1, Fal = 1LL<<60, mid;
    __int128 cost, classes;
    while(Fal - Tr > 1){
        mid = (Tr + Fal) >> 1;
        classes = 0;
        loop(i,0,n){
            cost = mid;
            if(b[i] >= a[i]){
                classes += ((cost-1) / b[i] + 1);
            }
            else{
                classes += min(((cost-1) / a[i] + 1), m);
                cost -= min(((cost-1) / a[i] + 1), m) * a[i];
                if(cost > 0)
                	classes += ((cost-1) / b[i] + 1);
            }
        }
        if(classes > all){
            Fal = mid;
        }
        else{
            Tr = mid;
        }
    }
    cout << Tr << "\n";
    return 0;
}
/*
3 3
19 4 5
2 6 2
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 394 ms 7328 KB Output is correct
12 Correct 409 ms 7368 KB Output is correct
13 Correct 258 ms 7372 KB Output is correct
14 Correct 389 ms 7352 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 241 ms 7320 KB Output is correct
17 Correct 333 ms 7308 KB Output is correct
18 Correct 328 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 241 ms 7320 KB Output is correct
3 Correct 333 ms 7308 KB Output is correct
4 Correct 328 ms 7260 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 292 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 161 ms 3924 KB Output is correct
14 Correct 106 ms 2588 KB Output is correct
15 Correct 79 ms 2144 KB Output is correct
16 Correct 64 ms 1716 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 5 ms 340 KB Output is correct
23 Correct 6 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 394 ms 7328 KB Output is correct
12 Correct 409 ms 7368 KB Output is correct
13 Correct 258 ms 7372 KB Output is correct
14 Correct 389 ms 7352 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 161 ms 3924 KB Output is correct
24 Correct 106 ms 2588 KB Output is correct
25 Correct 79 ms 2144 KB Output is correct
26 Correct 64 ms 1716 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 316 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 241 ms 7320 KB Output is correct
36 Correct 333 ms 7308 KB Output is correct
37 Correct 328 ms 7260 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 7 ms 344 KB Output is correct
46 Correct 15 ms 468 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 68 ms 1504 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 7 ms 424 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 224 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 197 ms 3780 KB Output is correct
56 Correct 88 ms 2640 KB Output is correct
57 Correct 138 ms 2612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 292 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 161 ms 3924 KB Output is correct
10 Correct 106 ms 2588 KB Output is correct
11 Correct 79 ms 2144 KB Output is correct
12 Correct 64 ms 1716 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 5 ms 340 KB Output is correct
19 Correct 6 ms 316 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 241 ms 7320 KB Output is correct
22 Correct 333 ms 7308 KB Output is correct
23 Correct 328 ms 7260 KB Output is correct
24 Correct 55 ms 1356 KB Output is correct
25 Correct 154 ms 3448 KB Output is correct
26 Correct 34 ms 956 KB Output is correct
27 Correct 323 ms 7520 KB Output is correct
28 Correct 329 ms 7284 KB Output is correct
29 Correct 312 ms 7228 KB Output is correct
30 Correct 327 ms 7324 KB Output is correct
31 Correct 367 ms 7324 KB Output is correct
32 Correct 256 ms 7284 KB Output is correct
33 Correct 434 ms 7320 KB Output is correct
34 Correct 258 ms 7204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 7 ms 340 KB Output is correct
11 Correct 394 ms 7328 KB Output is correct
12 Correct 409 ms 7368 KB Output is correct
13 Correct 258 ms 7372 KB Output is correct
14 Correct 389 ms 7352 KB Output is correct
15 Correct 0 ms 340 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 292 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 161 ms 3924 KB Output is correct
24 Correct 106 ms 2588 KB Output is correct
25 Correct 79 ms 2144 KB Output is correct
26 Correct 64 ms 1716 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 5 ms 340 KB Output is correct
33 Correct 6 ms 316 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 7 ms 344 KB Output is correct
42 Correct 15 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 68 ms 1504 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 7 ms 424 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 224 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 197 ms 3780 KB Output is correct
52 Correct 88 ms 2640 KB Output is correct
53 Correct 138 ms 2612 KB Output is correct
54 Correct 55 ms 1356 KB Output is correct
55 Correct 154 ms 3448 KB Output is correct
56 Correct 34 ms 956 KB Output is correct
57 Correct 323 ms 7520 KB Output is correct
58 Correct 329 ms 7284 KB Output is correct
59 Correct 312 ms 7228 KB Output is correct
60 Correct 327 ms 7324 KB Output is correct
61 Correct 367 ms 7324 KB Output is correct
62 Correct 256 ms 7284 KB Output is correct
63 Correct 434 ms 7320 KB Output is correct
64 Correct 258 ms 7204 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 241 ms 7320 KB Output is correct
67 Correct 333 ms 7308 KB Output is correct
68 Correct 328 ms 7260 KB Output is correct
69 Correct 47 ms 1052 KB Output is correct
70 Correct 12 ms 468 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 58 ms 1228 KB Output is correct
73 Correct 14 ms 468 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 407 ms 7324 KB Output is correct
76 Correct 394 ms 7428 KB Output is correct
77 Correct 410 ms 7260 KB Output is correct
78 Correct 398 ms 7292 KB Output is correct
79 Correct 403 ms 7328 KB Output is correct
80 Correct 393 ms 7308 KB Output is correct
81 Correct 317 ms 7324 KB Output is correct
82 Correct 409 ms 7328 KB Output is correct