답안 #703644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703644 2023-02-28T03:04:37 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
474 ms 7432 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){
            cost = x;
            if(x <= C[i] * M)
                day += (x - 1) / C[i] + 1;
            else
                day += M + (x - C[i] * M - 1) / B[i] + 1;
            day_test += min(((cost-1) / C[i] + 1), M);
            cost -= min(((cost-1) / C[i] + 1), M) * C[i];
            if(cost > 0)
                day_test += ((cost-1) / B[i] + 1);
            //if(day != day_test) exit(0);
            if(day_test > 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 248 ms 7324 KB Output is correct
12 Correct 257 ms 7324 KB Output is correct
13 Correct 202 ms 7396 KB Output is correct
14 Correct 176 ms 7236 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 78 ms 7328 KB Output is correct
17 Correct 266 ms 7400 KB Output is correct
18 Correct 249 ms 7276 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 78 ms 7328 KB Output is correct
3 Correct 266 ms 7400 KB Output is correct
4 Correct 249 ms 7276 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 0 ms 212 KB Output is correct
10 Correct 0 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 131 ms 3840 KB Output is correct
14 Correct 85 ms 2616 KB Output is correct
15 Correct 67 ms 2004 KB Output is correct
16 Correct 53 ms 1612 KB Output is correct
17 Correct 2 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 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 340 KB Output is correct
23 Correct 6 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 248 ms 7324 KB Output is correct
12 Correct 257 ms 7324 KB Output is correct
13 Correct 202 ms 7396 KB Output is correct
14 Correct 176 ms 7236 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 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 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 131 ms 3840 KB Output is correct
24 Correct 85 ms 2616 KB Output is correct
25 Correct 67 ms 2004 KB Output is correct
26 Correct 53 ms 1612 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 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 340 KB Output is correct
33 Correct 6 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 78 ms 7328 KB Output is correct
36 Correct 266 ms 7400 KB Output is correct
37 Correct 249 ms 7276 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 224 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 5 ms 392 KB Output is correct
46 Correct 8 ms 448 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 46 ms 1484 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 244 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 128 ms 3788 KB Output is correct
56 Correct 73 ms 2628 KB Output is correct
57 Correct 60 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 131 ms 3840 KB Output is correct
10 Correct 85 ms 2616 KB Output is correct
11 Correct 67 ms 2004 KB Output is correct
12 Correct 53 ms 1612 KB Output is correct
13 Correct 2 ms 212 KB Output is correct
14 Correct 0 ms 212 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 2 ms 340 KB Output is correct
19 Correct 6 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 78 ms 7328 KB Output is correct
22 Correct 266 ms 7400 KB Output is correct
23 Correct 249 ms 7276 KB Output is correct
24 Correct 55 ms 1384 KB Output is correct
25 Correct 143 ms 3396 KB Output is correct
26 Correct 35 ms 980 KB Output is correct
27 Correct 251 ms 7328 KB Output is correct
28 Correct 258 ms 7260 KB Output is correct
29 Correct 263 ms 7348 KB Output is correct
30 Correct 318 ms 7428 KB Output is correct
31 Correct 360 ms 7244 KB Output is correct
32 Correct 200 ms 7424 KB Output is correct
33 Correct 474 ms 7328 KB Output is correct
34 Correct 210 ms 7204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 0 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 248 ms 7324 KB Output is correct
12 Correct 257 ms 7324 KB Output is correct
13 Correct 202 ms 7396 KB Output is correct
14 Correct 176 ms 7236 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 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 1 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 131 ms 3840 KB Output is correct
24 Correct 85 ms 2616 KB Output is correct
25 Correct 67 ms 2004 KB Output is correct
26 Correct 53 ms 1612 KB Output is correct
27 Correct 2 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 1 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 340 KB Output is correct
33 Correct 6 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 0 ms 224 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 5 ms 392 KB Output is correct
42 Correct 8 ms 448 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 46 ms 1484 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 244 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 128 ms 3788 KB Output is correct
52 Correct 73 ms 2628 KB Output is correct
53 Correct 60 ms 2644 KB Output is correct
54 Correct 55 ms 1384 KB Output is correct
55 Correct 143 ms 3396 KB Output is correct
56 Correct 35 ms 980 KB Output is correct
57 Correct 251 ms 7328 KB Output is correct
58 Correct 258 ms 7260 KB Output is correct
59 Correct 263 ms 7348 KB Output is correct
60 Correct 318 ms 7428 KB Output is correct
61 Correct 360 ms 7244 KB Output is correct
62 Correct 200 ms 7424 KB Output is correct
63 Correct 474 ms 7328 KB Output is correct
64 Correct 210 ms 7204 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 78 ms 7328 KB Output is correct
67 Correct 266 ms 7400 KB Output is correct
68 Correct 249 ms 7276 KB Output is correct
69 Correct 39 ms 980 KB Output is correct
70 Correct 10 ms 468 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 63 ms 1288 KB Output is correct
73 Correct 13 ms 468 KB Output is correct
74 Correct 2 ms 340 KB Output is correct
75 Correct 265 ms 7372 KB Output is correct
76 Correct 274 ms 7216 KB Output is correct
77 Correct 289 ms 7324 KB Output is correct
78 Correct 351 ms 7364 KB Output is correct
79 Correct 393 ms 7248 KB Output is correct
80 Correct 397 ms 7432 KB Output is correct
81 Correct 393 ms 7404 KB Output is correct
82 Correct 332 ms 7324 KB Output is correct