Submission #923029

# Submission time Handle Problem Language Result Execution time Memory
923029 2024-02-06T13:00:03 Z ting39 Self Study (JOI22_ho_t2) C++17
0 / 100
354 ms 10836 KB
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m;
vector<int> a,b;
int dv(int x,int y){
	if(x<=0) return 0;
	if(y*(x/y)==x) return x/y;
	else return x/y+1;
}
bool check(int x){
	int emp=0,ext=0;
	for(int i=0;i<n;i++){
		if(x<=m*a[i]) emp+=dv(x,a[i]);
		else{
			ext+=dv(x-m*a[i],b[i]);
			emp+=m;
		}
	}//cout<<x<<' '<<ext<<' '<<emp<<' '<<n*m<<endl;
	return n*m>=ext+emp;
}
signed main(){
	cin>>n>>m;
	a.resize(n);
	b.resize(n);
	for(int &i:a) cin>>i;
	for(int i=0;i<n;i++){
		cin>>b[i];
		a[i]=max(a[i],b[i]);
	}
	int l=0,r=1e18+100,mid;
	while(r-l>1){
		mid=(l+r)/2;
		if(check(mid)) l=mid;
		else r=mid;
	}
	cout<<l<<endl;
}
# 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 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 436 KB Output is correct
7 Correct 1 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 4 ms 348 KB Output is correct
11 Correct 260 ms 10836 KB Output is correct
12 Correct 260 ms 10736 KB Output is correct
13 Correct 214 ms 8932 KB Output is correct
14 Incorrect 354 ms 8928 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 1 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 432 KB Output is correct
7 Correct 1 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 128 ms 5576 KB Output is correct
10 Correct 86 ms 3784 KB Output is correct
11 Correct 67 ms 2896 KB Output is correct
12 Correct 52 ms 2396 KB Output is correct
13 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 344 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 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 436 KB Output is correct
7 Correct 1 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 4 ms 348 KB Output is correct
11 Correct 260 ms 10836 KB Output is correct
12 Correct 260 ms 10736 KB Output is correct
13 Correct 214 ms 8932 KB Output is correct
14 Incorrect 354 ms 8928 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 1 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 432 KB Output is correct
7 Correct 1 ms 756 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 128 ms 5576 KB Output is correct
10 Correct 86 ms 3784 KB Output is correct
11 Correct 67 ms 2896 KB Output is correct
12 Correct 52 ms 2396 KB Output is correct
13 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 5 ms 344 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 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 436 KB Output is correct
7 Correct 1 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 4 ms 348 KB Output is correct
11 Correct 260 ms 10836 KB Output is correct
12 Correct 260 ms 10736 KB Output is correct
13 Correct 214 ms 8932 KB Output is correct
14 Incorrect 354 ms 8928 KB Output isn't correct
15 Halted 0 ms 0 KB -