# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
743734 |
2023-05-17T20:03:18 Z |
MODDI |
Self Study (JOI22_ho_t2) |
C++14 |
|
443 ms |
13740 KB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
ll m;
vl a, b;
bool check(ll atleast){
ll use = 0;
vl cur(n);
for(int i = 0; i < n; i++){
cur[i] = atleast;
if(a[i] <= b[i]){
use += m;
continue;
}
ll here = min(m, (atleast-1) / a[i] + 1);
use += m - here;
cur[i] = max(0LL, atleast - here * a[i]);
}
for(int i = 0; i < n; i++){
if(cur[i] == 0) continue;
ll here = (cur[i]-1)/b[i] + 1;
use -= here;
if(use < 0) return false;
}
return use>=0;
}
int main(){
cin>>n>>m;
a.resize(n);
b.resize(n);
for(int i = 0; i < n; i++) cin>>a[i];
for(int i = 0; i < n; i++) cin>>b[i];
ll l = 0, r = 1e18, ans;
while(l <= r){
ll mid = l + (r - l) / 2;
bool can = check(mid);
if(can){
ans = mid;
l = mid + 1;
}
else
r = mid - 1;
}
cout<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
456 KB |
Output is correct |
11 |
Correct |
372 ms |
7544 KB |
Output is correct |
12 |
Correct |
350 ms |
7468 KB |
Output is correct |
13 |
Correct |
226 ms |
7384 KB |
Output is correct |
14 |
Correct |
265 ms |
7460 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
94 ms |
7444 KB |
Output is correct |
17 |
Correct |
281 ms |
7544 KB |
Output is correct |
18 |
Correct |
266 ms |
7412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
94 ms |
7444 KB |
Output is correct |
3 |
Correct |
281 ms |
7544 KB |
Output is correct |
4 |
Correct |
266 ms |
7412 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
131 ms |
3928 KB |
Output is correct |
14 |
Correct |
90 ms |
2760 KB |
Output is correct |
15 |
Correct |
76 ms |
2184 KB |
Output is correct |
16 |
Correct |
65 ms |
1824 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 |
1 ms |
300 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
3 ms |
312 KB |
Output is correct |
23 |
Correct |
6 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
456 KB |
Output is correct |
11 |
Correct |
372 ms |
7544 KB |
Output is correct |
12 |
Correct |
350 ms |
7468 KB |
Output is correct |
13 |
Correct |
226 ms |
7384 KB |
Output is correct |
14 |
Correct |
265 ms |
7460 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
131 ms |
3928 KB |
Output is correct |
24 |
Correct |
90 ms |
2760 KB |
Output is correct |
25 |
Correct |
76 ms |
2184 KB |
Output is correct |
26 |
Correct |
65 ms |
1824 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
300 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
312 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
212 KB |
Output is correct |
35 |
Correct |
94 ms |
7444 KB |
Output is correct |
36 |
Correct |
281 ms |
7544 KB |
Output is correct |
37 |
Correct |
266 ms |
7412 KB |
Output is correct |
38 |
Correct |
1 ms |
300 KB |
Output is correct |
39 |
Correct |
1 ms |
304 KB |
Output is correct |
40 |
Correct |
1 ms |
212 KB |
Output is correct |
41 |
Correct |
1 ms |
212 KB |
Output is correct |
42 |
Correct |
1 ms |
212 KB |
Output is correct |
43 |
Correct |
1 ms |
296 KB |
Output is correct |
44 |
Correct |
1 ms |
300 KB |
Output is correct |
45 |
Correct |
6 ms |
468 KB |
Output is correct |
46 |
Correct |
12 ms |
724 KB |
Output is correct |
47 |
Correct |
2 ms |
212 KB |
Output is correct |
48 |
Correct |
60 ms |
1624 KB |
Output is correct |
49 |
Correct |
1 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
6 ms |
436 KB |
Output is correct |
52 |
Correct |
0 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 |
177 ms |
3956 KB |
Output is correct |
56 |
Correct |
71 ms |
2820 KB |
Output is correct |
57 |
Correct |
104 ms |
2756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
131 ms |
3928 KB |
Output is correct |
10 |
Correct |
90 ms |
2760 KB |
Output is correct |
11 |
Correct |
76 ms |
2184 KB |
Output is correct |
12 |
Correct |
65 ms |
1824 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
300 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
3 ms |
312 KB |
Output is correct |
19 |
Correct |
6 ms |
468 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
94 ms |
7444 KB |
Output is correct |
22 |
Correct |
281 ms |
7544 KB |
Output is correct |
23 |
Correct |
266 ms |
7412 KB |
Output is correct |
24 |
Correct |
63 ms |
1512 KB |
Output is correct |
25 |
Correct |
148 ms |
3580 KB |
Output is correct |
26 |
Correct |
32 ms |
1148 KB |
Output is correct |
27 |
Correct |
289 ms |
7436 KB |
Output is correct |
28 |
Correct |
277 ms |
7460 KB |
Output is correct |
29 |
Correct |
282 ms |
7464 KB |
Output is correct |
30 |
Correct |
296 ms |
7408 KB |
Output is correct |
31 |
Correct |
422 ms |
7456 KB |
Output is correct |
32 |
Correct |
181 ms |
8432 KB |
Output is correct |
33 |
Correct |
434 ms |
13740 KB |
Output is correct |
34 |
Correct |
185 ms |
8516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
300 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
5 ms |
456 KB |
Output is correct |
11 |
Correct |
372 ms |
7544 KB |
Output is correct |
12 |
Correct |
350 ms |
7468 KB |
Output is correct |
13 |
Correct |
226 ms |
7384 KB |
Output is correct |
14 |
Correct |
265 ms |
7460 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
16 |
Correct |
1 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 |
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 |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
131 ms |
3928 KB |
Output is correct |
24 |
Correct |
90 ms |
2760 KB |
Output is correct |
25 |
Correct |
76 ms |
2184 KB |
Output is correct |
26 |
Correct |
65 ms |
1824 KB |
Output is correct |
27 |
Correct |
1 ms |
212 KB |
Output is correct |
28 |
Correct |
1 ms |
212 KB |
Output is correct |
29 |
Correct |
0 ms |
212 KB |
Output is correct |
30 |
Correct |
1 ms |
300 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
3 ms |
312 KB |
Output is correct |
33 |
Correct |
6 ms |
468 KB |
Output is correct |
34 |
Correct |
1 ms |
300 KB |
Output is correct |
35 |
Correct |
1 ms |
304 KB |
Output is correct |
36 |
Correct |
1 ms |
212 KB |
Output is correct |
37 |
Correct |
1 ms |
212 KB |
Output is correct |
38 |
Correct |
1 ms |
212 KB |
Output is correct |
39 |
Correct |
1 ms |
296 KB |
Output is correct |
40 |
Correct |
1 ms |
300 KB |
Output is correct |
41 |
Correct |
6 ms |
468 KB |
Output is correct |
42 |
Correct |
12 ms |
724 KB |
Output is correct |
43 |
Correct |
2 ms |
212 KB |
Output is correct |
44 |
Correct |
60 ms |
1624 KB |
Output is correct |
45 |
Correct |
1 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
6 ms |
436 KB |
Output is correct |
48 |
Correct |
0 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 |
177 ms |
3956 KB |
Output is correct |
52 |
Correct |
71 ms |
2820 KB |
Output is correct |
53 |
Correct |
104 ms |
2756 KB |
Output is correct |
54 |
Correct |
63 ms |
1512 KB |
Output is correct |
55 |
Correct |
148 ms |
3580 KB |
Output is correct |
56 |
Correct |
32 ms |
1148 KB |
Output is correct |
57 |
Correct |
289 ms |
7436 KB |
Output is correct |
58 |
Correct |
277 ms |
7460 KB |
Output is correct |
59 |
Correct |
282 ms |
7464 KB |
Output is correct |
60 |
Correct |
296 ms |
7408 KB |
Output is correct |
61 |
Correct |
422 ms |
7456 KB |
Output is correct |
62 |
Correct |
181 ms |
8432 KB |
Output is correct |
63 |
Correct |
434 ms |
13740 KB |
Output is correct |
64 |
Correct |
185 ms |
8516 KB |
Output is correct |
65 |
Correct |
1 ms |
212 KB |
Output is correct |
66 |
Correct |
94 ms |
7444 KB |
Output is correct |
67 |
Correct |
281 ms |
7544 KB |
Output is correct |
68 |
Correct |
266 ms |
7412 KB |
Output is correct |
69 |
Correct |
43 ms |
1688 KB |
Output is correct |
70 |
Correct |
12 ms |
576 KB |
Output is correct |
71 |
Correct |
1 ms |
296 KB |
Output is correct |
72 |
Correct |
63 ms |
2124 KB |
Output is correct |
73 |
Correct |
15 ms |
724 KB |
Output is correct |
74 |
Correct |
2 ms |
212 KB |
Output is correct |
75 |
Correct |
372 ms |
13144 KB |
Output is correct |
76 |
Correct |
393 ms |
13128 KB |
Output is correct |
77 |
Correct |
398 ms |
13144 KB |
Output is correct |
78 |
Correct |
384 ms |
13152 KB |
Output is correct |
79 |
Correct |
443 ms |
13148 KB |
Output is correct |
80 |
Correct |
431 ms |
13140 KB |
Output is correct |
81 |
Correct |
373 ms |
11244 KB |
Output is correct |
82 |
Correct |
341 ms |
11152 KB |
Output is correct |