# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
831134 |
2023-08-19T19:21:04 Z |
jasmin |
Self Study (JOI22_ho_t2) |
C++17 |
|
211 ms |
11588 KB |
//JOI 2022 Final round
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF=1e18;
const int LM = LLONG_MAX;
bool possible(int x, int n, int m, vector<int>& a, vector<int>& b){
int d=0;
for(int i=0; i<n; i++){
if(a[i] > b[i]){
int da = (x+a[i]-1)/a[i];
int db = 0;
if(da > m){
da = m;
int x2 = x - (da*a[i]);
assert(0<x2);
db = (x2 + b[i]-1)/b[i];
}
if(LM-da < d) return false;
d += da;
if(LM-db < d) return false;
d += db;
}
else{
int db = (x+b[i] -1)/b[i];
if(LM-db < d) return false;
d += db;
}
}
assert(0<d);
return d <= (n*m);
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
vector<int> a(n);
for(int i=0; i<n; i++){
cin >> a[i];
}
vector<int> b(n);
for(int i=0; i<n; i++){
cin >> b[i];
}
int l=1; int r=INF;
int ans=1;
while(l <= r ){
int mi=l+(r-l)/2;
if(possible(mi, n, m, a, b)){
ans=mi;
l=mi+1;
}
else{
r=mi-1;
}
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
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 |
300 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 |
3 ms |
392 KB |
Output is correct |
11 |
Correct |
176 ms |
4984 KB |
Output is correct |
12 |
Correct |
180 ms |
4980 KB |
Output is correct |
13 |
Correct |
131 ms |
4948 KB |
Output is correct |
14 |
Correct |
182 ms |
4948 KB |
Output is correct |
15 |
Correct |
0 ms |
320 KB |
Output is correct |
16 |
Correct |
130 ms |
6112 KB |
Output is correct |
17 |
Correct |
148 ms |
11588 KB |
Output is correct |
18 |
Correct |
144 ms |
10756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
320 KB |
Output is correct |
2 |
Correct |
130 ms |
6112 KB |
Output is correct |
3 |
Correct |
148 ms |
11588 KB |
Output is correct |
4 |
Correct |
144 ms |
10756 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 |
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 |
71 ms |
2660 KB |
Output is correct |
14 |
Correct |
47 ms |
1888 KB |
Output is correct |
15 |
Correct |
36 ms |
1492 KB |
Output is correct |
16 |
Correct |
29 ms |
1188 KB |
Output is correct |
17 |
Correct |
1 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 |
300 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
3 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 |
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 |
300 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 |
3 ms |
392 KB |
Output is correct |
11 |
Correct |
176 ms |
4984 KB |
Output is correct |
12 |
Correct |
180 ms |
4980 KB |
Output is correct |
13 |
Correct |
131 ms |
4948 KB |
Output is correct |
14 |
Correct |
182 ms |
4948 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 |
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 |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
71 ms |
2660 KB |
Output is correct |
24 |
Correct |
47 ms |
1888 KB |
Output is correct |
25 |
Correct |
36 ms |
1492 KB |
Output is correct |
26 |
Correct |
29 ms |
1188 KB |
Output is correct |
27 |
Correct |
1 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 |
300 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
468 KB |
Output is correct |
34 |
Correct |
0 ms |
320 KB |
Output is correct |
35 |
Correct |
130 ms |
6112 KB |
Output is correct |
36 |
Correct |
148 ms |
11588 KB |
Output is correct |
37 |
Correct |
144 ms |
10756 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 |
1 ms |
212 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 |
4 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 |
32 ms |
2136 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
316 KB |
Output is correct |
51 |
Correct |
3 ms |
460 KB |
Output is correct |
52 |
Correct |
0 ms |
212 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
212 KB |
Output is correct |
55 |
Correct |
91 ms |
5460 KB |
Output is correct |
56 |
Correct |
45 ms |
3168 KB |
Output is correct |
57 |
Correct |
63 ms |
3152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
1 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 |
71 ms |
2660 KB |
Output is correct |
10 |
Correct |
47 ms |
1888 KB |
Output is correct |
11 |
Correct |
36 ms |
1492 KB |
Output is correct |
12 |
Correct |
29 ms |
1188 KB |
Output is correct |
13 |
Correct |
1 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 |
300 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
468 KB |
Output is correct |
20 |
Correct |
0 ms |
320 KB |
Output is correct |
21 |
Correct |
130 ms |
6112 KB |
Output is correct |
22 |
Correct |
148 ms |
11588 KB |
Output is correct |
23 |
Correct |
144 ms |
10756 KB |
Output is correct |
24 |
Correct |
30 ms |
1952 KB |
Output is correct |
25 |
Correct |
76 ms |
4952 KB |
Output is correct |
26 |
Correct |
16 ms |
1364 KB |
Output is correct |
27 |
Correct |
144 ms |
10720 KB |
Output is correct |
28 |
Correct |
145 ms |
10816 KB |
Output is correct |
29 |
Correct |
146 ms |
10820 KB |
Output is correct |
30 |
Correct |
155 ms |
10816 KB |
Output is correct |
31 |
Correct |
193 ms |
10720 KB |
Output is correct |
32 |
Correct |
151 ms |
6160 KB |
Output is correct |
33 |
Correct |
209 ms |
11472 KB |
Output is correct |
34 |
Correct |
151 ms |
6284 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
300 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 |
3 ms |
392 KB |
Output is correct |
11 |
Correct |
176 ms |
4984 KB |
Output is correct |
12 |
Correct |
180 ms |
4980 KB |
Output is correct |
13 |
Correct |
131 ms |
4948 KB |
Output is correct |
14 |
Correct |
182 ms |
4948 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 |
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 |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
71 ms |
2660 KB |
Output is correct |
24 |
Correct |
47 ms |
1888 KB |
Output is correct |
25 |
Correct |
36 ms |
1492 KB |
Output is correct |
26 |
Correct |
29 ms |
1188 KB |
Output is correct |
27 |
Correct |
1 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 |
300 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
3 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 |
1 ms |
212 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 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 |
4 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 |
32 ms |
2136 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
316 KB |
Output is correct |
47 |
Correct |
3 ms |
460 KB |
Output is correct |
48 |
Correct |
0 ms |
212 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
91 ms |
5460 KB |
Output is correct |
52 |
Correct |
45 ms |
3168 KB |
Output is correct |
53 |
Correct |
63 ms |
3152 KB |
Output is correct |
54 |
Correct |
30 ms |
1952 KB |
Output is correct |
55 |
Correct |
76 ms |
4952 KB |
Output is correct |
56 |
Correct |
16 ms |
1364 KB |
Output is correct |
57 |
Correct |
144 ms |
10720 KB |
Output is correct |
58 |
Correct |
145 ms |
10816 KB |
Output is correct |
59 |
Correct |
146 ms |
10820 KB |
Output is correct |
60 |
Correct |
155 ms |
10816 KB |
Output is correct |
61 |
Correct |
193 ms |
10720 KB |
Output is correct |
62 |
Correct |
151 ms |
6160 KB |
Output is correct |
63 |
Correct |
209 ms |
11472 KB |
Output is correct |
64 |
Correct |
151 ms |
6284 KB |
Output is correct |
65 |
Correct |
0 ms |
320 KB |
Output is correct |
66 |
Correct |
130 ms |
6112 KB |
Output is correct |
67 |
Correct |
148 ms |
11588 KB |
Output is correct |
68 |
Correct |
144 ms |
10756 KB |
Output is correct |
69 |
Correct |
23 ms |
1364 KB |
Output is correct |
70 |
Correct |
6 ms |
588 KB |
Output is correct |
71 |
Correct |
0 ms |
212 KB |
Output is correct |
72 |
Correct |
31 ms |
1828 KB |
Output is correct |
73 |
Correct |
7 ms |
596 KB |
Output is correct |
74 |
Correct |
1 ms |
272 KB |
Output is correct |
75 |
Correct |
185 ms |
10824 KB |
Output is correct |
76 |
Correct |
183 ms |
10728 KB |
Output is correct |
77 |
Correct |
184 ms |
10820 KB |
Output is correct |
78 |
Correct |
195 ms |
10716 KB |
Output is correct |
79 |
Correct |
210 ms |
10732 KB |
Output is correct |
80 |
Correct |
211 ms |
10776 KB |
Output is correct |
81 |
Correct |
196 ms |
8720 KB |
Output is correct |
82 |
Correct |
195 ms |
8832 KB |
Output is correct |