Submission #703651

# Submission time Handle Problem Language Result Execution time Memory
703651 2023-02-28T03:18:03 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
419 ms 7436 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...);
}

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;
    long long 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){
                break;
            }
        }
        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 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 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 4 ms 340 KB Output is correct
11 Correct 261 ms 7204 KB Output is correct
12 Correct 264 ms 7436 KB Output is correct
13 Correct 184 ms 7324 KB Output is correct
14 Correct 177 ms 7352 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 77 ms 7260 KB Output is correct
17 Correct 255 ms 7320 KB Output is correct
18 Correct 275 ms 7248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 77 ms 7260 KB Output is correct
3 Correct 255 ms 7320 KB Output is correct
4 Correct 275 ms 7248 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 125 ms 3720 KB Output is correct
14 Correct 101 ms 2636 KB Output is correct
15 Correct 62 ms 2052 KB Output is correct
16 Correct 51 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 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 2 ms 428 KB Output is correct
23 Correct 5 ms 340 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 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 4 ms 340 KB Output is correct
11 Correct 261 ms 7204 KB Output is correct
12 Correct 264 ms 7436 KB Output is correct
13 Correct 184 ms 7324 KB Output is correct
14 Correct 177 ms 7352 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 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 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 125 ms 3720 KB Output is correct
24 Correct 101 ms 2636 KB Output is correct
25 Correct 62 ms 2052 KB Output is correct
26 Correct 51 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 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 428 KB Output is correct
33 Correct 5 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 77 ms 7260 KB Output is correct
36 Correct 255 ms 7320 KB Output is correct
37 Correct 275 ms 7248 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 1 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 1 ms 212 KB Output is correct
45 Correct 5 ms 340 KB Output is correct
46 Correct 8 ms 492 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 48 ms 1488 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 0 ms 212 KB Output is correct
51 Correct 5 ms 340 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 153 ms 3660 KB Output is correct
56 Correct 65 ms 2636 KB Output is correct
57 Correct 58 ms 2656 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 1 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 125 ms 3720 KB Output is correct
10 Correct 101 ms 2636 KB Output is correct
11 Correct 62 ms 2052 KB Output is correct
12 Correct 51 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 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 428 KB Output is correct
19 Correct 5 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 77 ms 7260 KB Output is correct
22 Correct 255 ms 7320 KB Output is correct
23 Correct 275 ms 7248 KB Output is correct
24 Correct 53 ms 1356 KB Output is correct
25 Correct 139 ms 3376 KB Output is correct
26 Correct 29 ms 972 KB Output is correct
27 Correct 244 ms 7264 KB Output is correct
28 Correct 253 ms 7320 KB Output is correct
29 Correct 257 ms 7264 KB Output is correct
30 Correct 275 ms 7360 KB Output is correct
31 Correct 362 ms 7324 KB Output is correct
32 Correct 166 ms 7340 KB Output is correct
33 Correct 419 ms 7324 KB Output is correct
34 Correct 164 ms 7316 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 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 4 ms 340 KB Output is correct
11 Correct 261 ms 7204 KB Output is correct
12 Correct 264 ms 7436 KB Output is correct
13 Correct 184 ms 7324 KB Output is correct
14 Correct 177 ms 7352 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 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 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 125 ms 3720 KB Output is correct
24 Correct 101 ms 2636 KB Output is correct
25 Correct 62 ms 2052 KB Output is correct
26 Correct 51 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 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 428 KB Output is correct
33 Correct 5 ms 340 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 1 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 1 ms 212 KB Output is correct
41 Correct 5 ms 340 KB Output is correct
42 Correct 8 ms 492 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 48 ms 1488 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 0 ms 212 KB Output is correct
47 Correct 5 ms 340 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 153 ms 3660 KB Output is correct
52 Correct 65 ms 2636 KB Output is correct
53 Correct 58 ms 2656 KB Output is correct
54 Correct 53 ms 1356 KB Output is correct
55 Correct 139 ms 3376 KB Output is correct
56 Correct 29 ms 972 KB Output is correct
57 Correct 244 ms 7264 KB Output is correct
58 Correct 253 ms 7320 KB Output is correct
59 Correct 257 ms 7264 KB Output is correct
60 Correct 275 ms 7360 KB Output is correct
61 Correct 362 ms 7324 KB Output is correct
62 Correct 166 ms 7340 KB Output is correct
63 Correct 419 ms 7324 KB Output is correct
64 Correct 164 ms 7316 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 77 ms 7260 KB Output is correct
67 Correct 255 ms 7320 KB Output is correct
68 Correct 275 ms 7248 KB Output is correct
69 Correct 38 ms 1060 KB Output is correct
70 Correct 10 ms 504 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 57 ms 1292 KB Output is correct
73 Correct 12 ms 468 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 266 ms 7336 KB Output is correct
76 Correct 313 ms 7404 KB Output is correct
77 Correct 294 ms 7240 KB Output is correct
78 Correct 314 ms 7268 KB Output is correct
79 Correct 375 ms 7324 KB Output is correct
80 Correct 374 ms 7272 KB Output is correct
81 Correct 327 ms 7320 KB Output is correct
82 Correct 336 ms 7324 KB Output is correct