Submission #703641

# Submission time Handle Problem Language Result Execution time Memory
703641 2023-02-28T03:01:23 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
370 ms 13316 KB
#include <iostream>
#include <vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
long long A[300050], B[300050], C[300050];

void db(){
    cout << "\n";
}
template<class T, class ...U>
void db(T XXX, U ...YYY){
    cout << XXX << " ";  db(YYY...);
}

int main(){
//    ios::sync_with_stdio(false); cin.tie(0);
    long long N, M;
    cin >> 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 ok = 0, ng = 1LL << 60;
    auto check = [&](long long x) -> bool {
        long long day = 0, cost, day_test = 0;
        loop(i,0,N){
            if(x <= C[i] * M) day += (x - 1) / C[i] + 1;
            else day += M + (x - C[i] * M - 1) / B[i] + 1;

            cost = x;
            cost -= min(((cost-1) / C[i] + 1), M) * C[i];
            day_test += min(((cost-1) / C[i] + 1), M);
            if(cost > 0)
                day_test += ((cost-1) / B[i] + 1);
            //if(day != day_test) exit(0);
            if(day > N * M) return 0;
        }
        return 1;
    };
    while(ng - ok > 1){
        //db();
        long long mid = (ng + ok) / 2;
        if(check(mid)) ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 240 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 262 ms 13168 KB Output is correct
12 Correct 252 ms 13036 KB Output is correct
13 Correct 180 ms 11140 KB Output is correct
14 Correct 170 ms 11120 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 78 ms 8448 KB Output is correct
17 Correct 256 ms 13316 KB Output is correct
18 Correct 248 ms 12936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 78 ms 8448 KB Output is correct
3 Correct 256 ms 13316 KB Output is correct
4 Correct 248 ms 12936 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 1 ms 312 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 1 ms 304 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 128 ms 6712 KB Output is correct
14 Correct 82 ms 4476 KB Output is correct
15 Correct 62 ms 3396 KB Output is correct
16 Correct 51 ms 2860 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 0 ms 308 KB Output is correct
19 Correct 1 ms 308 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 5 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 240 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 262 ms 13168 KB Output is correct
12 Correct 252 ms 13036 KB Output is correct
13 Correct 180 ms 11140 KB Output is correct
14 Correct 170 ms 11120 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 128 ms 6712 KB Output is correct
24 Correct 82 ms 4476 KB Output is correct
25 Correct 62 ms 3396 KB Output is correct
26 Correct 51 ms 2860 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 308 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 78 ms 8448 KB Output is correct
36 Correct 256 ms 13316 KB Output is correct
37 Correct 248 ms 12936 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 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 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 5 ms 468 KB Output is correct
46 Correct 8 ms 596 KB Output is correct
47 Correct 2 ms 340 KB Output is correct
48 Correct 43 ms 2460 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 300 KB Output is correct
51 Correct 5 ms 448 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 308 KB Output is correct
54 Correct 0 ms 312 KB Output is correct
55 Correct 128 ms 6724 KB Output is correct
56 Correct 64 ms 3916 KB Output is correct
57 Correct 58 ms 3920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 304 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 304 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 128 ms 6712 KB Output is correct
10 Correct 82 ms 4476 KB Output is correct
11 Correct 62 ms 3396 KB Output is correct
12 Correct 51 ms 2860 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 0 ms 308 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 5 ms 468 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 78 ms 8448 KB Output is correct
22 Correct 256 ms 13316 KB Output is correct
23 Correct 248 ms 12936 KB Output is correct
24 Correct 53 ms 2248 KB Output is correct
25 Correct 137 ms 5992 KB Output is correct
26 Correct 28 ms 1600 KB Output is correct
27 Correct 241 ms 12748 KB Output is correct
28 Correct 250 ms 12876 KB Output is correct
29 Correct 253 ms 12900 KB Output is correct
30 Correct 294 ms 12776 KB Output is correct
31 Correct 352 ms 12936 KB Output is correct
32 Correct 151 ms 8472 KB Output is correct
33 Correct 354 ms 13284 KB Output is correct
34 Correct 147 ms 8496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 240 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 304 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 262 ms 13168 KB Output is correct
12 Correct 252 ms 13036 KB Output is correct
13 Correct 180 ms 11140 KB Output is correct
14 Correct 170 ms 11120 KB Output is correct
15 Correct 0 ms 304 KB Output is correct
16 Correct 1 ms 312 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 304 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 128 ms 6712 KB Output is correct
24 Correct 82 ms 4476 KB Output is correct
25 Correct 62 ms 3396 KB Output is correct
26 Correct 51 ms 2860 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 0 ms 308 KB Output is correct
29 Correct 1 ms 308 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 5 ms 468 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 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 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 468 KB Output is correct
42 Correct 8 ms 596 KB Output is correct
43 Correct 2 ms 340 KB Output is correct
44 Correct 43 ms 2460 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 300 KB Output is correct
47 Correct 5 ms 448 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 308 KB Output is correct
50 Correct 0 ms 312 KB Output is correct
51 Correct 128 ms 6724 KB Output is correct
52 Correct 64 ms 3916 KB Output is correct
53 Correct 58 ms 3920 KB Output is correct
54 Correct 53 ms 2248 KB Output is correct
55 Correct 137 ms 5992 KB Output is correct
56 Correct 28 ms 1600 KB Output is correct
57 Correct 241 ms 12748 KB Output is correct
58 Correct 250 ms 12876 KB Output is correct
59 Correct 253 ms 12900 KB Output is correct
60 Correct 294 ms 12776 KB Output is correct
61 Correct 352 ms 12936 KB Output is correct
62 Correct 151 ms 8472 KB Output is correct
63 Correct 354 ms 13284 KB Output is correct
64 Correct 147 ms 8496 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 78 ms 8448 KB Output is correct
67 Correct 256 ms 13316 KB Output is correct
68 Correct 248 ms 12936 KB Output is correct
69 Correct 37 ms 1576 KB Output is correct
70 Correct 10 ms 576 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 53 ms 2124 KB Output is correct
73 Correct 11 ms 744 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 248 ms 12708 KB Output is correct
76 Correct 262 ms 12936 KB Output is correct
77 Correct 272 ms 13000 KB Output is correct
78 Correct 303 ms 12960 KB Output is correct
79 Correct 352 ms 12824 KB Output is correct
80 Correct 370 ms 12908 KB Output is correct
81 Correct 273 ms 10820 KB Output is correct
82 Correct 265 ms 10888 KB Output is correct