Submission #703654

# Submission time Handle Problem Language Result Execution time Memory
703654 2023-02-28T03:21:18 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
403 ms 7452 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, cost;
    __int128 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
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 370 ms 7272 KB Output is correct
12 Correct 364 ms 7288 KB Output is correct
13 Correct 252 ms 7280 KB Output is correct
14 Correct 393 ms 7320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 232 ms 7328 KB Output is correct
17 Correct 328 ms 7364 KB Output is correct
18 Correct 312 ms 7328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 232 ms 7328 KB Output is correct
3 Correct 328 ms 7364 KB Output is correct
4 Correct 312 ms 7328 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 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 155 ms 3916 KB Output is correct
14 Correct 103 ms 2596 KB Output is correct
15 Correct 78 ms 2016 KB Output is correct
16 Correct 63 ms 1708 KB Output is correct
17 Correct 1 ms 212 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 4 ms 340 KB Output is correct
23 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 370 ms 7272 KB Output is correct
12 Correct 364 ms 7288 KB Output is correct
13 Correct 252 ms 7280 KB Output is correct
14 Correct 393 ms 7320 KB Output is correct
15 Correct 1 ms 212 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 155 ms 3916 KB Output is correct
24 Correct 103 ms 2596 KB Output is correct
25 Correct 78 ms 2016 KB Output is correct
26 Correct 63 ms 1708 KB Output is correct
27 Correct 1 ms 212 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 4 ms 340 KB Output is correct
33 Correct 7 ms 344 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 232 ms 7328 KB Output is correct
36 Correct 328 ms 7364 KB Output is correct
37 Correct 312 ms 7328 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 8 ms 436 KB Output is correct
46 Correct 11 ms 468 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 60 ms 1504 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 6 ms 424 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 0 ms 212 KB Output is correct
55 Correct 180 ms 3660 KB Output is correct
56 Correct 97 ms 2636 KB Output is correct
57 Correct 131 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 155 ms 3916 KB Output is correct
10 Correct 103 ms 2596 KB Output is correct
11 Correct 78 ms 2016 KB Output is correct
12 Correct 63 ms 1708 KB Output is correct
13 Correct 1 ms 212 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 4 ms 340 KB Output is correct
19 Correct 7 ms 344 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 232 ms 7328 KB Output is correct
22 Correct 328 ms 7364 KB Output is correct
23 Correct 312 ms 7328 KB Output is correct
24 Correct 55 ms 1388 KB Output is correct
25 Correct 154 ms 3444 KB Output is correct
26 Correct 33 ms 1036 KB Output is correct
27 Correct 311 ms 7328 KB Output is correct
28 Correct 318 ms 7280 KB Output is correct
29 Correct 310 ms 7408 KB Output is correct
30 Correct 325 ms 7308 KB Output is correct
31 Correct 358 ms 7320 KB Output is correct
32 Correct 267 ms 7448 KB Output is correct
33 Correct 393 ms 7324 KB Output is correct
34 Correct 267 ms 7320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 340 KB Output is correct
11 Correct 370 ms 7272 KB Output is correct
12 Correct 364 ms 7288 KB Output is correct
13 Correct 252 ms 7280 KB Output is correct
14 Correct 393 ms 7320 KB Output is correct
15 Correct 1 ms 212 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 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 155 ms 3916 KB Output is correct
24 Correct 103 ms 2596 KB Output is correct
25 Correct 78 ms 2016 KB Output is correct
26 Correct 63 ms 1708 KB Output is correct
27 Correct 1 ms 212 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 4 ms 340 KB Output is correct
33 Correct 7 ms 344 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 8 ms 436 KB Output is correct
42 Correct 11 ms 468 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 60 ms 1504 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 6 ms 424 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 180 ms 3660 KB Output is correct
52 Correct 97 ms 2636 KB Output is correct
53 Correct 131 ms 2648 KB Output is correct
54 Correct 55 ms 1388 KB Output is correct
55 Correct 154 ms 3444 KB Output is correct
56 Correct 33 ms 1036 KB Output is correct
57 Correct 311 ms 7328 KB Output is correct
58 Correct 318 ms 7280 KB Output is correct
59 Correct 310 ms 7408 KB Output is correct
60 Correct 325 ms 7308 KB Output is correct
61 Correct 358 ms 7320 KB Output is correct
62 Correct 267 ms 7448 KB Output is correct
63 Correct 393 ms 7324 KB Output is correct
64 Correct 267 ms 7320 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 232 ms 7328 KB Output is correct
67 Correct 328 ms 7364 KB Output is correct
68 Correct 312 ms 7328 KB Output is correct
69 Correct 45 ms 1032 KB Output is correct
70 Correct 10 ms 504 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 56 ms 1312 KB Output is correct
73 Correct 13 ms 544 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 350 ms 7452 KB Output is correct
76 Correct 359 ms 7288 KB Output is correct
77 Correct 359 ms 7304 KB Output is correct
78 Correct 372 ms 7320 KB Output is correct
79 Correct 403 ms 7320 KB Output is correct
80 Correct 382 ms 7244 KB Output is correct
81 Correct 319 ms 7200 KB Output is correct
82 Correct 403 ms 7328 KB Output is correct