# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703656 |
2023-02-28T03:28:17 Z |
niter |
Self Study (JOI22_ho_t2) |
C++14 |
|
248 ms |
5068 KB |
#include<bits/stdc++.h>
#include<random>
using namespace std;
template<typename T> void _do(T x){cerr<<x<<"\n";}
template<typename T,typename ...U> void _do(T x,U ...y){cerr<<x<<", ";_do(y...);}
#define dbg(...) cerr<<#__VA_ARGS__<<" = ";_do(__VA_ARGS__);
#define float double
#define ss(n) fixed<<setprecision(n)
#define ll long long
#define int ll
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define ld long double
#define pb push_back
#define pii pair<int,int>
#define rep(i,a) for(int i=1;i<=a;i++)
#define rep0(i,a) for(int i=0;i<a;i++)
#define F first
#define S second
#define uni(a) a.resize(distance(a.begin(),unique(a.begin(),a.end())));
#define unisort(a) sort(a.begin(),a.end()); uni(a);
ll gcd(ll a,ll b){if(b==0) return a; return gcd(b,a%b);}
const ld pi=3.14159265358979323846264338327950288419716939931;
const int lar=3e18;
const int mol1=1e9+7;
const int mol2=998244353;
void solve()
{
int n,m;
cin>>n>>m;
int a[n+1],b[n+1];
rep(i,n) cin>>a[i];
rep(i,n) cin>>b[i];
rep(i,n) if(a[i]<b[i]) a[i]=b[i];
int l=m,r=8e18;
int ans;
while(l<=r){
__int128 tt=0;
int mid=l+r+1>>1;
rep(i,n){
if(a[i]>b[i]){
if(a[i]*m>=mid){
tt+=((mid+a[i]-1)/a[i]);
}
else{
tt+=m;
int g1=mid-a[i]*m;
tt+=((g1+b[i]-1)/b[i]);
}
}
else{
tt+=((mid+b[i]-1)/b[i]);
}
}
if(tt<=n*m) {
ans=mid;
l=mid+1;
}
else{
r=mid-1;
}
}
cout<<ans<<"\n";
}
signed main()
{
IO
solve();
return 0;
}
Compilation message
Main.cpp: In function 'void solve()':
Main.cpp:43:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
43 | int mid=l+r+1>>1;
| ~~~^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
181 ms |
4948 KB |
Output is correct |
12 |
Correct |
178 ms |
5068 KB |
Output is correct |
13 |
Correct |
160 ms |
4948 KB |
Output is correct |
14 |
Correct |
215 ms |
4948 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
202 ms |
4948 KB |
Output is correct |
17 |
Correct |
204 ms |
5000 KB |
Output is correct |
18 |
Correct |
166 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
202 ms |
4948 KB |
Output is correct |
3 |
Correct |
204 ms |
5000 KB |
Output is correct |
4 |
Correct |
166 ms |
4992 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
1 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 |
91 ms |
2644 KB |
Output is correct |
14 |
Correct |
55 ms |
1876 KB |
Output is correct |
15 |
Correct |
42 ms |
1364 KB |
Output is correct |
16 |
Correct |
35 ms |
1236 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 |
212 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
4 ms |
340 KB |
Output is correct |
23 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
181 ms |
4948 KB |
Output is correct |
12 |
Correct |
178 ms |
5068 KB |
Output is correct |
13 |
Correct |
160 ms |
4948 KB |
Output is correct |
14 |
Correct |
215 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 |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 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 |
91 ms |
2644 KB |
Output is correct |
24 |
Correct |
55 ms |
1876 KB |
Output is correct |
25 |
Correct |
42 ms |
1364 KB |
Output is correct |
26 |
Correct |
35 ms |
1236 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 |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
4 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
202 ms |
4948 KB |
Output is correct |
36 |
Correct |
204 ms |
5000 KB |
Output is correct |
37 |
Correct |
166 ms |
4992 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 |
0 ms |
212 KB |
Output is correct |
42 |
Correct |
1 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 |
3 ms |
340 KB |
Output is correct |
46 |
Correct |
6 ms |
460 KB |
Output is correct |
47 |
Correct |
1 ms |
212 KB |
Output is correct |
48 |
Correct |
32 ms |
1108 KB |
Output is correct |
49 |
Correct |
0 ms |
212 KB |
Output is correct |
50 |
Correct |
1 ms |
212 KB |
Output is correct |
51 |
Correct |
3 ms |
340 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 |
89 ms |
2516 KB |
Output is correct |
56 |
Correct |
55 ms |
1748 KB |
Output is correct |
57 |
Correct |
72 ms |
1876 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 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 |
91 ms |
2644 KB |
Output is correct |
10 |
Correct |
55 ms |
1876 KB |
Output is correct |
11 |
Correct |
42 ms |
1364 KB |
Output is correct |
12 |
Correct |
35 ms |
1236 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 |
212 KB |
Output is correct |
17 |
Correct |
0 ms |
212 KB |
Output is correct |
18 |
Correct |
4 ms |
340 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
202 ms |
4948 KB |
Output is correct |
22 |
Correct |
204 ms |
5000 KB |
Output is correct |
23 |
Correct |
166 ms |
4992 KB |
Output is correct |
24 |
Correct |
33 ms |
988 KB |
Output is correct |
25 |
Correct |
86 ms |
2400 KB |
Output is correct |
26 |
Correct |
18 ms |
724 KB |
Output is correct |
27 |
Correct |
162 ms |
4948 KB |
Output is correct |
28 |
Correct |
165 ms |
4948 KB |
Output is correct |
29 |
Correct |
166 ms |
4948 KB |
Output is correct |
30 |
Correct |
175 ms |
4996 KB |
Output is correct |
31 |
Correct |
216 ms |
4992 KB |
Output is correct |
32 |
Correct |
224 ms |
4992 KB |
Output is correct |
33 |
Correct |
248 ms |
4948 KB |
Output is correct |
34 |
Correct |
222 ms |
4992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
3 ms |
340 KB |
Output is correct |
11 |
Correct |
181 ms |
4948 KB |
Output is correct |
12 |
Correct |
178 ms |
5068 KB |
Output is correct |
13 |
Correct |
160 ms |
4948 KB |
Output is correct |
14 |
Correct |
215 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 |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 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 |
91 ms |
2644 KB |
Output is correct |
24 |
Correct |
55 ms |
1876 KB |
Output is correct |
25 |
Correct |
42 ms |
1364 KB |
Output is correct |
26 |
Correct |
35 ms |
1236 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 |
212 KB |
Output is correct |
31 |
Correct |
0 ms |
212 KB |
Output is correct |
32 |
Correct |
4 ms |
340 KB |
Output is correct |
33 |
Correct |
3 ms |
340 KB |
Output is correct |
34 |
Correct |
0 ms |
212 KB |
Output is correct |
35 |
Correct |
0 ms |
212 KB |
Output is correct |
36 |
Correct |
0 ms |
212 KB |
Output is correct |
37 |
Correct |
0 ms |
212 KB |
Output is correct |
38 |
Correct |
1 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 |
3 ms |
340 KB |
Output is correct |
42 |
Correct |
6 ms |
460 KB |
Output is correct |
43 |
Correct |
1 ms |
212 KB |
Output is correct |
44 |
Correct |
32 ms |
1108 KB |
Output is correct |
45 |
Correct |
0 ms |
212 KB |
Output is correct |
46 |
Correct |
1 ms |
212 KB |
Output is correct |
47 |
Correct |
3 ms |
340 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 |
89 ms |
2516 KB |
Output is correct |
52 |
Correct |
55 ms |
1748 KB |
Output is correct |
53 |
Correct |
72 ms |
1876 KB |
Output is correct |
54 |
Correct |
33 ms |
988 KB |
Output is correct |
55 |
Correct |
86 ms |
2400 KB |
Output is correct |
56 |
Correct |
18 ms |
724 KB |
Output is correct |
57 |
Correct |
162 ms |
4948 KB |
Output is correct |
58 |
Correct |
165 ms |
4948 KB |
Output is correct |
59 |
Correct |
166 ms |
4948 KB |
Output is correct |
60 |
Correct |
175 ms |
4996 KB |
Output is correct |
61 |
Correct |
216 ms |
4992 KB |
Output is correct |
62 |
Correct |
224 ms |
4992 KB |
Output is correct |
63 |
Correct |
248 ms |
4948 KB |
Output is correct |
64 |
Correct |
222 ms |
4992 KB |
Output is correct |
65 |
Correct |
0 ms |
212 KB |
Output is correct |
66 |
Correct |
202 ms |
4948 KB |
Output is correct |
67 |
Correct |
204 ms |
5000 KB |
Output is correct |
68 |
Correct |
166 ms |
4992 KB |
Output is correct |
69 |
Correct |
24 ms |
824 KB |
Output is correct |
70 |
Correct |
7 ms |
440 KB |
Output is correct |
71 |
Correct |
0 ms |
212 KB |
Output is correct |
72 |
Correct |
33 ms |
980 KB |
Output is correct |
73 |
Correct |
8 ms |
468 KB |
Output is correct |
74 |
Correct |
1 ms |
212 KB |
Output is correct |
75 |
Correct |
180 ms |
4948 KB |
Output is correct |
76 |
Correct |
178 ms |
4996 KB |
Output is correct |
77 |
Correct |
183 ms |
4988 KB |
Output is correct |
78 |
Correct |
193 ms |
4948 KB |
Output is correct |
79 |
Correct |
219 ms |
4988 KB |
Output is correct |
80 |
Correct |
226 ms |
5068 KB |
Output is correct |
81 |
Correct |
221 ms |
4992 KB |
Output is correct |
82 |
Correct |
212 ms |
4948 KB |
Output is correct |