Submission #923003

# Submission time Handle Problem Language Result Execution time Memory
923003 2024-02-06T12:24:53 Z ting39 Self Study (JOI22_ho_t2) C++17
0 / 100
520 ms 10908 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++){
		emp+=max(m-dv(x,a[i]),0LL);
		ext+=max(dv(x-m*a[i],b[i]),0LL);
	}
	return emp>=ext;
}
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 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 329 ms 10908 KB Output is correct
12 Correct 322 ms 10832 KB Output is correct
13 Correct 301 ms 8684 KB Output is correct
14 Incorrect 520 ms 8784 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 344 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 172 ms 5444 KB Output is correct
10 Correct 108 ms 3920 KB Output is correct
11 Correct 81 ms 2900 KB Output is correct
12 Correct 65 ms 2528 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 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Incorrect 9 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 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 329 ms 10908 KB Output is correct
12 Correct 322 ms 10832 KB Output is correct
13 Correct 301 ms 8684 KB Output is correct
14 Incorrect 520 ms 8784 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 344 KB Output is correct
4 Correct 0 ms 600 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 172 ms 5444 KB Output is correct
10 Correct 108 ms 3920 KB Output is correct
11 Correct 81 ms 2900 KB Output is correct
12 Correct 65 ms 2528 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 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Incorrect 9 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 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 348 KB Output is correct
11 Correct 329 ms 10908 KB Output is correct
12 Correct 322 ms 10832 KB Output is correct
13 Correct 301 ms 8684 KB Output is correct
14 Incorrect 520 ms 8784 KB Output isn't correct
15 Halted 0 ms 0 KB -