답안 #703655

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703655 2023-02-28T03:25:31 Z niter Self Study (JOI22_ho_t2) C++14
100 / 100
485 ms 5096 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];

/*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 XX, __int128 YY){
    return (XX > YY) ? (YY) : (XX);
}

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];
    long long l = 1, r = (long long)(9e18), mid;
    __int128 cost, classes;
    while(l != r){
        mid = (l + r + 1) >> 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 > n * m){
            r = mid - 1;
        }
        else{
            l = mid;
        }
    }
    cout << l << "\n";
    return 0;
}
/*
3 3
19 4 5
2 6 2
*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:21: warning: variable 'all' set but not used [-Wunused-but-set-variable]
   28 |     long long n, m, all;
      |                     ^~~
# 결과 실행 시간 메모리 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 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Correct 407 ms 4972 KB Output is correct
12 Correct 419 ms 4972 KB Output is correct
13 Correct 281 ms 4992 KB Output is correct
14 Correct 410 ms 4972 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 442 ms 4924 KB Output is correct
17 Correct 445 ms 4940 KB Output is correct
18 Correct 404 ms 4992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 442 ms 4924 KB Output is correct
3 Correct 445 ms 4940 KB Output is correct
4 Correct 404 ms 4992 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 1 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 0 ms 212 KB Output is correct
13 Correct 202 ms 2548 KB Output is correct
14 Correct 137 ms 1740 KB Output is correct
15 Correct 117 ms 1368 KB Output is correct
16 Correct 82 ms 1116 KB Output is correct
17 Correct 2 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 7 ms 340 KB Output is correct
23 Correct 8 ms 340 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 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 6 ms 376 KB Output is correct
11 Correct 407 ms 4972 KB Output is correct
12 Correct 419 ms 4972 KB Output is correct
13 Correct 281 ms 4992 KB Output is correct
14 Correct 410 ms 4972 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 1 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 0 ms 212 KB Output is correct
23 Correct 202 ms 2548 KB Output is correct
24 Correct 137 ms 1740 KB Output is correct
25 Correct 117 ms 1368 KB Output is correct
26 Correct 82 ms 1116 KB Output is correct
27 Correct 2 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 7 ms 340 KB Output is correct
33 Correct 8 ms 340 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 442 ms 4924 KB Output is correct
36 Correct 445 ms 4940 KB Output is correct
37 Correct 404 ms 4992 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 0 ms 212 KB Output is correct
42 Correct 1 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 8 ms 340 KB Output is correct
46 Correct 13 ms 444 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 71 ms 1096 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 7 ms 368 KB Output is correct
52 Correct 1 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 222 ms 2616 KB Output is correct
56 Correct 89 ms 1740 KB Output is correct
57 Correct 144 ms 1856 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 1 ms 212 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 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 202 ms 2548 KB Output is correct
10 Correct 137 ms 1740 KB Output is correct
11 Correct 117 ms 1368 KB Output is correct
12 Correct 82 ms 1116 KB Output is correct
13 Correct 2 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 7 ms 340 KB Output is correct
19 Correct 8 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 442 ms 4924 KB Output is correct
22 Correct 445 ms 4940 KB Output is correct
23 Correct 404 ms 4992 KB Output is correct
24 Correct 76 ms 980 KB Output is correct
25 Correct 185 ms 2520 KB Output is correct
26 Correct 45 ms 724 KB Output is correct
27 Correct 407 ms 4928 KB Output is correct
28 Correct 434 ms 4908 KB Output is correct
29 Correct 485 ms 4972 KB Output is correct
30 Correct 437 ms 4972 KB Output is correct
31 Correct 400 ms 4984 KB Output is correct
32 Correct 416 ms 4948 KB Output is correct
33 Correct 457 ms 5048 KB Output is correct
34 Correct 448 ms 4940 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 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 6 ms 376 KB Output is correct
11 Correct 407 ms 4972 KB Output is correct
12 Correct 419 ms 4972 KB Output is correct
13 Correct 281 ms 4992 KB Output is correct
14 Correct 410 ms 4972 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 1 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 0 ms 212 KB Output is correct
23 Correct 202 ms 2548 KB Output is correct
24 Correct 137 ms 1740 KB Output is correct
25 Correct 117 ms 1368 KB Output is correct
26 Correct 82 ms 1116 KB Output is correct
27 Correct 2 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 7 ms 340 KB Output is correct
33 Correct 8 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 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 1 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 8 ms 340 KB Output is correct
42 Correct 13 ms 444 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 71 ms 1096 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 7 ms 368 KB Output is correct
48 Correct 1 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 222 ms 2616 KB Output is correct
52 Correct 89 ms 1740 KB Output is correct
53 Correct 144 ms 1856 KB Output is correct
54 Correct 76 ms 980 KB Output is correct
55 Correct 185 ms 2520 KB Output is correct
56 Correct 45 ms 724 KB Output is correct
57 Correct 407 ms 4928 KB Output is correct
58 Correct 434 ms 4908 KB Output is correct
59 Correct 485 ms 4972 KB Output is correct
60 Correct 437 ms 4972 KB Output is correct
61 Correct 400 ms 4984 KB Output is correct
62 Correct 416 ms 4948 KB Output is correct
63 Correct 457 ms 5048 KB Output is correct
64 Correct 448 ms 4940 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 442 ms 4924 KB Output is correct
67 Correct 445 ms 4940 KB Output is correct
68 Correct 404 ms 4992 KB Output is correct
69 Correct 55 ms 796 KB Output is correct
70 Correct 14 ms 340 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 60 ms 964 KB Output is correct
73 Correct 14 ms 456 KB Output is correct
74 Correct 1 ms 212 KB Output is correct
75 Correct 410 ms 4972 KB Output is correct
76 Correct 415 ms 5068 KB Output is correct
77 Correct 411 ms 4876 KB Output is correct
78 Correct 420 ms 4932 KB Output is correct
79 Correct 450 ms 4976 KB Output is correct
80 Correct 416 ms 4980 KB Output is correct
81 Correct 329 ms 4972 KB Output is correct
82 Correct 433 ms 5096 KB Output is correct