# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1018853 |
2024-07-10T10:13:32 Z |
vjudge1 |
Self Study (JOI22_ho_t2) |
C++17 |
|
127 ms |
11528 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 |
1 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 |
456 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 |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
83 ms |
9912 KB |
Output is correct |
12 |
Correct |
85 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8340 KB |
Output is correct |
14 |
Correct |
43 ms |
8280 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
21 ms |
6236 KB |
Output is correct |
17 |
Correct |
63 ms |
10088 KB |
Output is correct |
18 |
Correct |
67 ms |
10132 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
21 ms |
6236 KB |
Output is correct |
3 |
Correct |
63 ms |
10088 KB |
Output is correct |
4 |
Correct |
67 ms |
10132 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 |
448 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 |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
31 ms |
5608 KB |
Output is correct |
14 |
Correct |
22 ms |
3944 KB |
Output is correct |
15 |
Correct |
15 ms |
2908 KB |
Output is correct |
16 |
Correct |
13 ms |
2396 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
448 KB |
Output is correct |
19 |
Correct |
0 ms |
344 KB |
Output is correct |
20 |
Correct |
0 ms |
344 KB |
Output is correct |
21 |
Correct |
1 ms |
596 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 |
1 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 |
456 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 |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
83 ms |
9912 KB |
Output is correct |
12 |
Correct |
85 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8340 KB |
Output is correct |
14 |
Correct |
43 ms |
8280 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
448 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 |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
31 ms |
5608 KB |
Output is correct |
24 |
Correct |
22 ms |
3944 KB |
Output is correct |
25 |
Correct |
15 ms |
2908 KB |
Output is correct |
26 |
Correct |
13 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
448 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
596 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 |
6236 KB |
Output is correct |
36 |
Correct |
63 ms |
10088 KB |
Output is correct |
37 |
Correct |
67 ms |
10132 KB |
Output is correct |
38 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
46 |
Correct |
4 ms |
604 KB |
Output is correct |
47 |
Correct |
1 ms |
860 KB |
Output is correct |
48 |
Correct |
14 ms |
2272 KB |
Output is correct |
49 |
Correct |
1 ms |
348 KB |
Output is correct |
50 |
Correct |
0 ms |
348 KB |
Output is correct |
51 |
Correct |
1 ms |
468 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 |
43 ms |
5644 KB |
Output is correct |
56 |
Correct |
18 ms |
3164 KB |
Output is correct |
57 |
Correct |
19 ms |
3152 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
448 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 |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
31 ms |
5608 KB |
Output is correct |
10 |
Correct |
22 ms |
3944 KB |
Output is correct |
11 |
Correct |
15 ms |
2908 KB |
Output is correct |
12 |
Correct |
13 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
448 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
0 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
596 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 |
6236 KB |
Output is correct |
22 |
Correct |
63 ms |
10088 KB |
Output is correct |
23 |
Correct |
67 ms |
10132 KB |
Output is correct |
24 |
Correct |
13 ms |
1968 KB |
Output is correct |
25 |
Correct |
32 ms |
4956 KB |
Output is correct |
26 |
Correct |
7 ms |
1372 KB |
Output is correct |
27 |
Correct |
61 ms |
10880 KB |
Output is correct |
28 |
Correct |
62 ms |
10836 KB |
Output is correct |
29 |
Correct |
68 ms |
10932 KB |
Output is correct |
30 |
Correct |
68 ms |
10936 KB |
Output is correct |
31 |
Correct |
81 ms |
10832 KB |
Output is correct |
32 |
Correct |
43 ms |
6236 KB |
Output is correct |
33 |
Correct |
88 ms |
11528 KB |
Output is correct |
34 |
Correct |
44 ms |
6236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
456 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 |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
83 ms |
9912 KB |
Output is correct |
12 |
Correct |
85 ms |
9812 KB |
Output is correct |
13 |
Correct |
50 ms |
8340 KB |
Output is correct |
14 |
Correct |
43 ms |
8280 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
448 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 |
344 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
31 ms |
5608 KB |
Output is correct |
24 |
Correct |
22 ms |
3944 KB |
Output is correct |
25 |
Correct |
15 ms |
2908 KB |
Output is correct |
26 |
Correct |
13 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
448 KB |
Output is correct |
29 |
Correct |
0 ms |
344 KB |
Output is correct |
30 |
Correct |
0 ms |
344 KB |
Output is correct |
31 |
Correct |
1 ms |
596 KB |
Output is correct |
32 |
Correct |
1 ms |
348 KB |
Output is correct |
33 |
Correct |
1 ms |
604 KB |
Output is correct |
34 |
Correct |
1 ms |
344 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 |
604 KB |
Output is correct |
42 |
Correct |
4 ms |
604 KB |
Output is correct |
43 |
Correct |
1 ms |
860 KB |
Output is correct |
44 |
Correct |
14 ms |
2272 KB |
Output is correct |
45 |
Correct |
1 ms |
348 KB |
Output is correct |
46 |
Correct |
0 ms |
348 KB |
Output is correct |
47 |
Correct |
1 ms |
468 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 |
43 ms |
5644 KB |
Output is correct |
52 |
Correct |
18 ms |
3164 KB |
Output is correct |
53 |
Correct |
19 ms |
3152 KB |
Output is correct |
54 |
Correct |
13 ms |
1968 KB |
Output is correct |
55 |
Correct |
32 ms |
4956 KB |
Output is correct |
56 |
Correct |
7 ms |
1372 KB |
Output is correct |
57 |
Correct |
61 ms |
10880 KB |
Output is correct |
58 |
Correct |
62 ms |
10836 KB |
Output is correct |
59 |
Correct |
68 ms |
10932 KB |
Output is correct |
60 |
Correct |
68 ms |
10936 KB |
Output is correct |
61 |
Correct |
81 ms |
10832 KB |
Output is correct |
62 |
Correct |
43 ms |
6236 KB |
Output is correct |
63 |
Correct |
88 ms |
11528 KB |
Output is correct |
64 |
Correct |
44 ms |
6236 KB |
Output is correct |
65 |
Correct |
0 ms |
348 KB |
Output is correct |
66 |
Correct |
21 ms |
6236 KB |
Output is correct |
67 |
Correct |
63 ms |
10088 KB |
Output is correct |
68 |
Correct |
67 ms |
10132 KB |
Output is correct |
69 |
Correct |
16 ms |
1372 KB |
Output is correct |
70 |
Correct |
3 ms |
604 KB |
Output is correct |
71 |
Correct |
0 ms |
348 KB |
Output is correct |
72 |
Correct |
18 ms |
1884 KB |
Output is correct |
73 |
Correct |
3 ms |
604 KB |
Output is correct |
74 |
Correct |
1 ms |
600 KB |
Output is correct |
75 |
Correct |
93 ms |
10684 KB |
Output is correct |
76 |
Correct |
94 ms |
10836 KB |
Output is correct |
77 |
Correct |
99 ms |
10904 KB |
Output is correct |
78 |
Correct |
110 ms |
10936 KB |
Output is correct |
79 |
Correct |
127 ms |
10936 KB |
Output is correct |
80 |
Correct |
124 ms |
10832 KB |
Output is correct |
81 |
Correct |
75 ms |
8796 KB |
Output is correct |
82 |
Correct |
73 ms |
8788 KB |
Output is correct |