Submission #751962

# Submission time Handle Problem Language Result Execution time Memory
751962 2023-06-02T01:46:43 Z willychan Self Study (JOI22_ho_t2) C++14
0 / 100
465 ms 8408 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds

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;
}


int 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 0 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 4 ms 440 KB Output is correct
11 Correct 225 ms 8408 KB Output is correct
12 Correct 224 ms 8404 KB Output is correct
13 Correct 235 ms 6492 KB Output is correct
14 Incorrect 465 ms 6484 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 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
9 Correct 121 ms 4292 KB Output is correct
10 Correct 76 ms 3028 KB Output is correct
11 Correct 57 ms 2356 KB Output is correct
12 Correct 47 ms 1944 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 9 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 0 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 4 ms 440 KB Output is correct
11 Correct 225 ms 8408 KB Output is correct
12 Correct 224 ms 8404 KB Output is correct
13 Correct 235 ms 6492 KB Output is correct
14 Incorrect 465 ms 6484 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 0 ms 212 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 0 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 0 ms 212 KB Output is correct
9 Correct 121 ms 4292 KB Output is correct
10 Correct 76 ms 3028 KB Output is correct
11 Correct 57 ms 2356 KB Output is correct
12 Correct 47 ms 1944 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 9 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 0 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 4 ms 440 KB Output is correct
11 Correct 225 ms 8408 KB Output is correct
12 Correct 224 ms 8404 KB Output is correct
13 Correct 235 ms 6492 KB Output is correct
14 Incorrect 465 ms 6484 KB Output isn't correct
15 Halted 0 ms 0 KB -