# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
528143 |
2022-02-19T11:49:47 Z |
doowey |
Self Study (JOI22_ho_t2) |
C++14 |
|
330 ms |
11904 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)3e5 + 10;
ll A[N];
ll B[N];
ll C[N];
int main(){
fastIO;
//freopen("in.txt","r",stdin);
int n;
cin >> n;
ll m;
cin >> m;
for(int i = 1; i <= n; i ++ ){
cin >> A[i];
}
for(int i = 1; i <= n; i ++ ){
cin >> B[i];
A[i] = max(A[i], B[i]);
}
ll li = 0;
ll ri = (ll)2e18;
ll mid;
ll nd;
while(li + 1 < ri){
mid = (li + ri) / 2;
ll can;
nd = 0;
for(int i = 1; i <= n; i ++ ){
can = (mid + A[i] - 1) / A[i];
if(can <= m){
nd += m - can;
C[i] = 0;
}
else{
C[i] = mid - A[i] * 1ll * m;
}
}
for(int i = 1; i <= n; i ++ ){
nd -= (C[i] + B[i] - 1) / B[i];
if(nd < 0) break;
}
if(nd >= 0){
li = mid;
}
else{
ri = mid;
}
}
cout << li << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
181 ms |
7312 KB |
Output is correct |
12 |
Correct |
180 ms |
7340 KB |
Output is correct |
13 |
Correct |
175 ms |
7388 KB |
Output is correct |
14 |
Correct |
175 ms |
7344 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
198 ms |
7340 KB |
Output is correct |
17 |
Correct |
209 ms |
7408 KB |
Output is correct |
18 |
Correct |
179 ms |
7316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
198 ms |
7340 KB |
Output is correct |
3 |
Correct |
209 ms |
7408 KB |
Output is correct |
4 |
Correct |
179 ms |
7316 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
332 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
332 KB |
Output is correct |
13 |
Correct |
106 ms |
3832 KB |
Output is correct |
14 |
Correct |
70 ms |
2664 KB |
Output is correct |
15 |
Correct |
50 ms |
2072 KB |
Output is correct |
16 |
Correct |
44 ms |
1740 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
3 ms |
332 KB |
Output is correct |
23 |
Correct |
4 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
181 ms |
7312 KB |
Output is correct |
12 |
Correct |
180 ms |
7340 KB |
Output is correct |
13 |
Correct |
175 ms |
7388 KB |
Output is correct |
14 |
Correct |
175 ms |
7344 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
106 ms |
3832 KB |
Output is correct |
24 |
Correct |
70 ms |
2664 KB |
Output is correct |
25 |
Correct |
50 ms |
2072 KB |
Output is correct |
26 |
Correct |
44 ms |
1740 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
204 KB |
Output is correct |
35 |
Correct |
198 ms |
7340 KB |
Output is correct |
36 |
Correct |
209 ms |
7408 KB |
Output is correct |
37 |
Correct |
179 ms |
7316 KB |
Output is correct |
38 |
Correct |
0 ms |
332 KB |
Output is correct |
39 |
Correct |
0 ms |
332 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
0 ms |
204 KB |
Output is correct |
42 |
Correct |
1 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
204 KB |
Output is correct |
44 |
Correct |
0 ms |
332 KB |
Output is correct |
45 |
Correct |
4 ms |
460 KB |
Output is correct |
46 |
Correct |
7 ms |
460 KB |
Output is correct |
47 |
Correct |
2 ms |
332 KB |
Output is correct |
48 |
Correct |
36 ms |
1520 KB |
Output is correct |
49 |
Correct |
0 ms |
332 KB |
Output is correct |
50 |
Correct |
1 ms |
332 KB |
Output is correct |
51 |
Correct |
4 ms |
332 KB |
Output is correct |
52 |
Correct |
0 ms |
332 KB |
Output is correct |
53 |
Correct |
0 ms |
332 KB |
Output is correct |
54 |
Correct |
0 ms |
332 KB |
Output is correct |
55 |
Correct |
104 ms |
3800 KB |
Output is correct |
56 |
Correct |
61 ms |
2660 KB |
Output is correct |
57 |
Correct |
62 ms |
2676 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
106 ms |
3832 KB |
Output is correct |
10 |
Correct |
70 ms |
2664 KB |
Output is correct |
11 |
Correct |
50 ms |
2072 KB |
Output is correct |
12 |
Correct |
44 ms |
1740 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
0 ms |
332 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
0 ms |
204 KB |
Output is correct |
17 |
Correct |
0 ms |
332 KB |
Output is correct |
18 |
Correct |
3 ms |
332 KB |
Output is correct |
19 |
Correct |
4 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
204 KB |
Output is correct |
21 |
Correct |
198 ms |
7340 KB |
Output is correct |
22 |
Correct |
209 ms |
7408 KB |
Output is correct |
23 |
Correct |
179 ms |
7316 KB |
Output is correct |
24 |
Correct |
45 ms |
1356 KB |
Output is correct |
25 |
Correct |
119 ms |
3464 KB |
Output is correct |
26 |
Correct |
24 ms |
972 KB |
Output is correct |
27 |
Correct |
200 ms |
7340 KB |
Output is correct |
28 |
Correct |
219 ms |
7408 KB |
Output is correct |
29 |
Correct |
211 ms |
7292 KB |
Output is correct |
30 |
Correct |
238 ms |
7336 KB |
Output is correct |
31 |
Correct |
301 ms |
7376 KB |
Output is correct |
32 |
Correct |
239 ms |
7880 KB |
Output is correct |
33 |
Correct |
237 ms |
8900 KB |
Output is correct |
34 |
Correct |
258 ms |
7620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
0 ms |
332 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
332 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
0 ms |
332 KB |
Output is correct |
10 |
Correct |
3 ms |
332 KB |
Output is correct |
11 |
Correct |
181 ms |
7312 KB |
Output is correct |
12 |
Correct |
180 ms |
7340 KB |
Output is correct |
13 |
Correct |
175 ms |
7388 KB |
Output is correct |
14 |
Correct |
175 ms |
7344 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
0 ms |
204 KB |
Output is correct |
18 |
Correct |
0 ms |
332 KB |
Output is correct |
19 |
Correct |
0 ms |
204 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
0 ms |
332 KB |
Output is correct |
22 |
Correct |
0 ms |
332 KB |
Output is correct |
23 |
Correct |
106 ms |
3832 KB |
Output is correct |
24 |
Correct |
70 ms |
2664 KB |
Output is correct |
25 |
Correct |
50 ms |
2072 KB |
Output is correct |
26 |
Correct |
44 ms |
1740 KB |
Output is correct |
27 |
Correct |
1 ms |
332 KB |
Output is correct |
28 |
Correct |
0 ms |
332 KB |
Output is correct |
29 |
Correct |
0 ms |
204 KB |
Output is correct |
30 |
Correct |
0 ms |
204 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
3 ms |
332 KB |
Output is correct |
33 |
Correct |
4 ms |
332 KB |
Output is correct |
34 |
Correct |
0 ms |
332 KB |
Output is correct |
35 |
Correct |
0 ms |
332 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
0 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
0 ms |
332 KB |
Output is correct |
41 |
Correct |
4 ms |
460 KB |
Output is correct |
42 |
Correct |
7 ms |
460 KB |
Output is correct |
43 |
Correct |
2 ms |
332 KB |
Output is correct |
44 |
Correct |
36 ms |
1520 KB |
Output is correct |
45 |
Correct |
0 ms |
332 KB |
Output is correct |
46 |
Correct |
1 ms |
332 KB |
Output is correct |
47 |
Correct |
4 ms |
332 KB |
Output is correct |
48 |
Correct |
0 ms |
332 KB |
Output is correct |
49 |
Correct |
0 ms |
332 KB |
Output is correct |
50 |
Correct |
0 ms |
332 KB |
Output is correct |
51 |
Correct |
104 ms |
3800 KB |
Output is correct |
52 |
Correct |
61 ms |
2660 KB |
Output is correct |
53 |
Correct |
62 ms |
2676 KB |
Output is correct |
54 |
Correct |
45 ms |
1356 KB |
Output is correct |
55 |
Correct |
119 ms |
3464 KB |
Output is correct |
56 |
Correct |
24 ms |
972 KB |
Output is correct |
57 |
Correct |
200 ms |
7340 KB |
Output is correct |
58 |
Correct |
219 ms |
7408 KB |
Output is correct |
59 |
Correct |
211 ms |
7292 KB |
Output is correct |
60 |
Correct |
238 ms |
7336 KB |
Output is correct |
61 |
Correct |
301 ms |
7376 KB |
Output is correct |
62 |
Correct |
239 ms |
7880 KB |
Output is correct |
63 |
Correct |
237 ms |
8900 KB |
Output is correct |
64 |
Correct |
258 ms |
7620 KB |
Output is correct |
65 |
Correct |
0 ms |
204 KB |
Output is correct |
66 |
Correct |
198 ms |
7340 KB |
Output is correct |
67 |
Correct |
209 ms |
7408 KB |
Output is correct |
68 |
Correct |
179 ms |
7316 KB |
Output is correct |
69 |
Correct |
33 ms |
1156 KB |
Output is correct |
70 |
Correct |
8 ms |
516 KB |
Output is correct |
71 |
Correct |
0 ms |
204 KB |
Output is correct |
72 |
Correct |
46 ms |
1492 KB |
Output is correct |
73 |
Correct |
10 ms |
504 KB |
Output is correct |
74 |
Correct |
2 ms |
340 KB |
Output is correct |
75 |
Correct |
213 ms |
9324 KB |
Output is correct |
76 |
Correct |
222 ms |
9028 KB |
Output is correct |
77 |
Correct |
235 ms |
8576 KB |
Output is correct |
78 |
Correct |
264 ms |
7636 KB |
Output is correct |
79 |
Correct |
330 ms |
9168 KB |
Output is correct |
80 |
Correct |
322 ms |
11904 KB |
Output is correct |
81 |
Correct |
228 ms |
8928 KB |
Output is correct |
82 |
Correct |
227 ms |
9168 KB |
Output is correct |