Submission #751963

# Submission time Handle Problem Language Result Execution time Memory
751963 2023-06-02T01:47:43 Z willychan Self Study (JOI22_ho_t2) C++14
0 / 100
476 ms 5152 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds
#define int ll
ll n,m;
vector<int> a;
vector<int> b;
bool check(ll k){
	ll left = 0;							
	for(int i=0;i<n;i++){
		ll c = k;
		ll g = (c/a[i])+(c%a[i]!=0);
		if(g>m)	{
			c-=(m*a[i]);
			left -= (c/b[i])+(c%b[i]!=0);
		}else{
			left+=m-g;			
		}
	}
	return left>=0;
}


signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	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];
		a[i] = max(a[i],b[i]);
	}
	ll l = 0; ll r = 1e18;				
	while(r-l>1){
		ll mid = l+((r-l)/2);
		if(check(mid)){
			l = mid;
		}else{
			r = mid;	
		}
	}
	cout<<l<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 226 ms 5140 KB Output is correct
12 Correct 221 ms 5144 KB Output is correct
13 Correct 238 ms 5152 KB Output is correct
14 Incorrect 476 ms 5076 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 316 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 115 ms 2772 KB Output is correct
10 Correct 79 ms 2004 KB Output is correct
11 Correct 58 ms 1620 KB Output is correct
12 Correct 48 ms 1364 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 10 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 226 ms 5140 KB Output is correct
12 Correct 221 ms 5144 KB Output is correct
13 Correct 238 ms 5152 KB Output is correct
14 Incorrect 476 ms 5076 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 316 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 115 ms 2772 KB Output is correct
10 Correct 79 ms 2004 KB Output is correct
11 Correct 58 ms 1620 KB Output is correct
12 Correct 48 ms 1364 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 10 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 312 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 468 KB Output is correct
11 Correct 226 ms 5140 KB Output is correct
12 Correct 221 ms 5144 KB Output is correct
13 Correct 238 ms 5152 KB Output is correct
14 Incorrect 476 ms 5076 KB Output isn't correct
15 Halted 0 ms 0 KB -