# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018857 |
2024-07-10T10:15:05 Z |
vjudge1 |
Self Study (JOI22_ho_t2) |
C++17 |
|
127 ms |
10836 KB |
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define ROF(i,m,n) for(int i=m;i<=n;i++)
#define vi vector<int>
#define pb push_back
#define alle(a) a.begin(),a.end()
#define rall(n) rbegin(n),rend(n)
#define int long long
#define vecs vector<int>
#define ll long long
#define ss second
#define ff first
const int INF = 1e9;
const int MOD = 1e9 + 7;
void solve(){
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];
}
auto check = [&](int m1){
int ans = 0;
int b1 = 0;
int a1 = 0;
for(int i = 0;i < n;i++){
a1 = 0;
b1 = 0;
if(a[i] <= b[i]){
b1 += (m1 + b[i] - 1) / b[i];
}
if(a[i] > b[i]){
int f = a[i] * m;
if(f >= m1){
a1 += (m1 + a[i] - 1)/ a[i];
}
else{
a1 += m;
b1 += (m1 - f + b[i] - 1)/b[i];
}
}
ans += b1;
ans += a1;
if(ans > n * 1ll * m){
return false;
}
}
if(ans <= m * n){
return true;
}
else{
return false;
}
};
int l = 1, r = 1e18 + 1;
while(1 < r - l){
int m2 = (r + l)>> 1;
if(check( m2 )){
l = m2;
}
else{
r = m2;
}
}
if(check(r)){
cout<<r;
}
else{
cout<<l;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int ti = 1;
while (ti--) {
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
456 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
86 ms |
9760 KB |
Output is correct |
12 |
Correct |
83 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8284 KB |
Output is correct |
14 |
Correct |
43 ms |
8276 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
21 ms |
6120 KB |
Output is correct |
17 |
Correct |
63 ms |
10836 KB |
Output is correct |
18 |
Correct |
61 ms |
9808 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
21 ms |
6120 KB |
Output is correct |
3 |
Correct |
63 ms |
10836 KB |
Output is correct |
4 |
Correct |
61 ms |
9808 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
32 ms |
5188 KB |
Output is correct |
14 |
Correct |
21 ms |
3672 KB |
Output is correct |
15 |
Correct |
15 ms |
2908 KB |
Output is correct |
16 |
Correct |
14 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
1 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
456 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
86 ms |
9760 KB |
Output is correct |
12 |
Correct |
83 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8284 KB |
Output is correct |
14 |
Correct |
43 ms |
8276 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
32 ms |
5188 KB |
Output is correct |
24 |
Correct |
21 ms |
3672 KB |
Output is correct |
25 |
Correct |
15 ms |
2908 KB |
Output is correct |
26 |
Correct |
14 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
21 ms |
6120 KB |
Output is correct |
36 |
Correct |
63 ms |
10836 KB |
Output is correct |
37 |
Correct |
61 ms |
9808 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
0 ms |
348 KB |
Output is correct |
42 |
Correct |
0 ms |
348 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
640 KB |
Output is correct |
46 |
Correct |
2 ms |
604 KB |
Output is correct |
47 |
Correct |
0 ms |
348 KB |
Output is correct |
48 |
Correct |
14 ms |
2140 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
1 ms |
600 KB |
Output is correct |
52 |
Correct |
0 ms |
348 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
0 ms |
348 KB |
Output is correct |
55 |
Correct |
42 ms |
5212 KB |
Output is correct |
56 |
Correct |
20 ms |
3164 KB |
Output is correct |
57 |
Correct |
15 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
32 ms |
5188 KB |
Output is correct |
10 |
Correct |
21 ms |
3672 KB |
Output is correct |
11 |
Correct |
15 ms |
2908 KB |
Output is correct |
12 |
Correct |
14 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
348 KB |
Output is correct |
19 |
Correct |
1 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
21 ms |
6120 KB |
Output is correct |
22 |
Correct |
63 ms |
10836 KB |
Output is correct |
23 |
Correct |
61 ms |
9808 KB |
Output is correct |
24 |
Correct |
13 ms |
1880 KB |
Output is correct |
25 |
Correct |
33 ms |
4700 KB |
Output is correct |
26 |
Correct |
7 ms |
1372 KB |
Output is correct |
27 |
Correct |
62 ms |
9616 KB |
Output is correct |
28 |
Correct |
63 ms |
9548 KB |
Output is correct |
29 |
Correct |
65 ms |
9552 KB |
Output is correct |
30 |
Correct |
70 ms |
9620 KB |
Output is correct |
31 |
Correct |
83 ms |
9556 KB |
Output is correct |
32 |
Correct |
46 ms |
6236 KB |
Output is correct |
33 |
Correct |
88 ms |
10576 KB |
Output is correct |
34 |
Correct |
43 ms |
6232 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
456 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
2 ms |
576 KB |
Output is correct |
11 |
Correct |
86 ms |
9760 KB |
Output is correct |
12 |
Correct |
83 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8284 KB |
Output is correct |
14 |
Correct |
43 ms |
8276 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
32 ms |
5188 KB |
Output is correct |
24 |
Correct |
21 ms |
3672 KB |
Output is correct |
25 |
Correct |
15 ms |
2908 KB |
Output is correct |
26 |
Correct |
14 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
0 ms |
348 KB |
Output is correct |
29 |
Correct |
0 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
348 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
0 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
0 ms |
348 KB |
Output is correct |
41 |
Correct |
1 ms |
640 KB |
Output is correct |
42 |
Correct |
2 ms |
604 KB |
Output is correct |
43 |
Correct |
0 ms |
348 KB |
Output is correct |
44 |
Correct |
14 ms |
2140 KB |
Output is correct |
45 |
Correct |
0 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
600 KB |
Output is correct |
48 |
Correct |
0 ms |
348 KB |
Output is correct |
49 |
Correct |
0 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
42 ms |
5212 KB |
Output is correct |
52 |
Correct |
20 ms |
3164 KB |
Output is correct |
53 |
Correct |
15 ms |
3160 KB |
Output is correct |
54 |
Correct |
13 ms |
1880 KB |
Output is correct |
55 |
Correct |
33 ms |
4700 KB |
Output is correct |
56 |
Correct |
7 ms |
1372 KB |
Output is correct |
57 |
Correct |
62 ms |
9616 KB |
Output is correct |
58 |
Correct |
63 ms |
9548 KB |
Output is correct |
59 |
Correct |
65 ms |
9552 KB |
Output is correct |
60 |
Correct |
70 ms |
9620 KB |
Output is correct |
61 |
Correct |
83 ms |
9556 KB |
Output is correct |
62 |
Correct |
46 ms |
6236 KB |
Output is correct |
63 |
Correct |
88 ms |
10576 KB |
Output is correct |
64 |
Correct |
43 ms |
6232 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Correct |
21 ms |
6120 KB |
Output is correct |
67 |
Correct |
63 ms |
10836 KB |
Output is correct |
68 |
Correct |
61 ms |
9808 KB |
Output is correct |
69 |
Correct |
13 ms |
1368 KB |
Output is correct |
70 |
Correct |
3 ms |
600 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
17 ms |
1884 KB |
Output is correct |
73 |
Correct |
3 ms |
600 KB |
Output is correct |
74 |
Correct |
1 ms |
348 KB |
Output is correct |
75 |
Correct |
89 ms |
9552 KB |
Output is correct |
76 |
Correct |
101 ms |
9592 KB |
Output is correct |
77 |
Correct |
99 ms |
9748 KB |
Output is correct |
78 |
Correct |
115 ms |
9528 KB |
Output is correct |
79 |
Correct |
127 ms |
9552 KB |
Output is correct |
80 |
Correct |
127 ms |
9568 KB |
Output is correct |
81 |
Correct |
77 ms |
8212 KB |
Output is correct |
82 |
Correct |
74 ms |
8156 KB |
Output is correct |