# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
541917 |
2022-03-24T19:48:37 Z |
AdamGS |
Self Study (JOI22_ho_t2) |
C++17 |
|
274 ms |
11464 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
#define rep(a, b) for(int a = 0; a < (b); ++a)
const int LIM=3e5+7;
const ll INF=1e18+7;
ll A[LIM], B[LIM], n, m;
bool f(ll x) {
ll ile=0;
rep(i, n) {
ll p=(x+A[i]-1)/A[i];
p=min(p, m);
ll a=x-p*A[i];
ile+=p;
if(a>0) ile+=(a+B[i]-1)/B[i];
if(ile>n*m) return false;
}
return true;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> n >> m;
rep(i, n) cin >> A[i];
rep(i, n) {
cin >> B[i];
A[i]=max(A[i], B[i]);
}
ll p=0, k=INF;
while(p<k) {
ll sr=(p+k+1)/2;
if(f(sr)) p=sr; else k=sr-1;
}
cout << p << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
106 ms |
10700 KB |
Output is correct |
12 |
Correct |
101 ms |
10764 KB |
Output is correct |
13 |
Correct |
98 ms |
8820 KB |
Output is correct |
14 |
Correct |
78 ms |
8780 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
33 ms |
6092 KB |
Output is correct |
17 |
Correct |
134 ms |
11464 KB |
Output is correct |
18 |
Correct |
102 ms |
10808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
33 ms |
6092 KB |
Output is correct |
3 |
Correct |
134 ms |
11464 KB |
Output is correct |
4 |
Correct |
102 ms |
10808 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
328 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 |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
63 ms |
5516 KB |
Output is correct |
14 |
Correct |
42 ms |
3816 KB |
Output is correct |
15 |
Correct |
28 ms |
2896 KB |
Output is correct |
16 |
Correct |
25 ms |
2324 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
328 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
3 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 |
328 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
106 ms |
10700 KB |
Output is correct |
12 |
Correct |
101 ms |
10764 KB |
Output is correct |
13 |
Correct |
98 ms |
8820 KB |
Output is correct |
14 |
Correct |
78 ms |
8780 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
328 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 |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
63 ms |
5516 KB |
Output is correct |
24 |
Correct |
42 ms |
3816 KB |
Output is correct |
25 |
Correct |
28 ms |
2896 KB |
Output is correct |
26 |
Correct |
25 ms |
2324 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
328 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
328 KB |
Output is correct |
35 |
Correct |
33 ms |
6092 KB |
Output is correct |
36 |
Correct |
134 ms |
11464 KB |
Output is correct |
37 |
Correct |
102 ms |
10808 KB |
Output is correct |
38 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
324 KB |
Output is correct |
44 |
Correct |
1 ms |
212 KB |
Output is correct |
45 |
Correct |
3 ms |
468 KB |
Output is correct |
46 |
Correct |
6 ms |
596 KB |
Output is correct |
47 |
Correct |
1 ms |
340 KB |
Output is correct |
48 |
Correct |
23 ms |
2120 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
324 KB |
Output is correct |
51 |
Correct |
3 ms |
432 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 |
328 KB |
Output is correct |
55 |
Correct |
57 ms |
5432 KB |
Output is correct |
56 |
Correct |
43 ms |
3148 KB |
Output is correct |
57 |
Correct |
33 ms |
3108 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 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 |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
63 ms |
5516 KB |
Output is correct |
10 |
Correct |
42 ms |
3816 KB |
Output is correct |
11 |
Correct |
28 ms |
2896 KB |
Output is correct |
12 |
Correct |
25 ms |
2324 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
328 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
328 KB |
Output is correct |
21 |
Correct |
33 ms |
6092 KB |
Output is correct |
22 |
Correct |
134 ms |
11464 KB |
Output is correct |
23 |
Correct |
102 ms |
10808 KB |
Output is correct |
24 |
Correct |
35 ms |
1876 KB |
Output is correct |
25 |
Correct |
91 ms |
5020 KB |
Output is correct |
26 |
Correct |
16 ms |
1364 KB |
Output is correct |
27 |
Correct |
122 ms |
10700 KB |
Output is correct |
28 |
Correct |
111 ms |
10808 KB |
Output is correct |
29 |
Correct |
120 ms |
10764 KB |
Output is correct |
30 |
Correct |
173 ms |
10872 KB |
Output is correct |
31 |
Correct |
223 ms |
10728 KB |
Output is correct |
32 |
Correct |
160 ms |
6176 KB |
Output is correct |
33 |
Correct |
274 ms |
11464 KB |
Output is correct |
34 |
Correct |
169 ms |
6120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
328 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 |
328 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
3 ms |
468 KB |
Output is correct |
11 |
Correct |
106 ms |
10700 KB |
Output is correct |
12 |
Correct |
101 ms |
10764 KB |
Output is correct |
13 |
Correct |
98 ms |
8820 KB |
Output is correct |
14 |
Correct |
78 ms |
8780 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
328 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 |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
63 ms |
5516 KB |
Output is correct |
24 |
Correct |
42 ms |
3816 KB |
Output is correct |
25 |
Correct |
28 ms |
2896 KB |
Output is correct |
26 |
Correct |
25 ms |
2324 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
328 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
340 KB |
Output is correct |
32 |
Correct |
1 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
324 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
3 ms |
468 KB |
Output is correct |
42 |
Correct |
6 ms |
596 KB |
Output is correct |
43 |
Correct |
1 ms |
340 KB |
Output is correct |
44 |
Correct |
23 ms |
2120 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
324 KB |
Output is correct |
47 |
Correct |
3 ms |
432 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 |
328 KB |
Output is correct |
51 |
Correct |
57 ms |
5432 KB |
Output is correct |
52 |
Correct |
43 ms |
3148 KB |
Output is correct |
53 |
Correct |
33 ms |
3108 KB |
Output is correct |
54 |
Correct |
35 ms |
1876 KB |
Output is correct |
55 |
Correct |
91 ms |
5020 KB |
Output is correct |
56 |
Correct |
16 ms |
1364 KB |
Output is correct |
57 |
Correct |
122 ms |
10700 KB |
Output is correct |
58 |
Correct |
111 ms |
10808 KB |
Output is correct |
59 |
Correct |
120 ms |
10764 KB |
Output is correct |
60 |
Correct |
173 ms |
10872 KB |
Output is correct |
61 |
Correct |
223 ms |
10728 KB |
Output is correct |
62 |
Correct |
160 ms |
6176 KB |
Output is correct |
63 |
Correct |
274 ms |
11464 KB |
Output is correct |
64 |
Correct |
169 ms |
6120 KB |
Output is correct |
65 |
Correct |
1 ms |
328 KB |
Output is correct |
66 |
Correct |
33 ms |
6092 KB |
Output is correct |
67 |
Correct |
134 ms |
11464 KB |
Output is correct |
68 |
Correct |
102 ms |
10808 KB |
Output is correct |
69 |
Correct |
27 ms |
1456 KB |
Output is correct |
70 |
Correct |
8 ms |
596 KB |
Output is correct |
71 |
Correct |
1 ms |
212 KB |
Output is correct |
72 |
Correct |
41 ms |
1788 KB |
Output is correct |
73 |
Correct |
10 ms |
708 KB |
Output is correct |
74 |
Correct |
2 ms |
332 KB |
Output is correct |
75 |
Correct |
123 ms |
10828 KB |
Output is correct |
76 |
Correct |
129 ms |
10772 KB |
Output is correct |
77 |
Correct |
147 ms |
10804 KB |
Output is correct |
78 |
Correct |
217 ms |
10720 KB |
Output is correct |
79 |
Correct |
249 ms |
10700 KB |
Output is correct |
80 |
Correct |
261 ms |
10808 KB |
Output is correct |
81 |
Correct |
235 ms |
8820 KB |
Output is correct |
82 |
Correct |
225 ms |
8820 KB |
Output is correct |