Submission #885847

# Submission time Handle Problem Language Result Execution time Memory
885847 2023-12-10T21:22:50 Z NintsiChkhaidze Self Study (JOI22_ho_t2) C++17
0 / 100
195 ms 13280 KB
#include <bits/stdc++.h>
#define pb push_back
#define s second
#define f first
#define pii pair<int,int>
#define ll long long
#define int ll
using namespace std;

const int N = 3e5 + 3;

int a[N],b[N],n,m,cur[N];

bool check(int x){

	int need=0,have=0;
	for (int i = 1; i <= n; i++){
		cur[i] = max(a[i],b[i]) * m;
		if (cur[i] > x){
			have += (cur[i] - x) / max(a[i],b[i]);
		}else if (cur[i] < x){
			need += (x - cur[i] + b[i] - 1)/b[i];
		}
	}

	return (have >= need);
}
signed main (){
    ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
	
	cin>>n>>m;

	for (int i = 1; i <= n; i++) 
		cin >> a[i];
	
	for (int i = 1; i <= n; i++)
		cin >> b[i];

	int l = 0,r = 3e14,res=0;
	while (l <= r){
		int mid = (l + r)/2;
		if (check(mid)){
			res=mid;
			l=mid+1;
		}else{
			r=mid-1;
		}
	}
	cout<<res;
}

# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4556 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 116 ms 13280 KB Output is correct
12 Correct 115 ms 13272 KB Output is correct
13 Correct 102 ms 11108 KB Output is correct
14 Incorrect 195 ms 11608 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 58 ms 9556 KB Output is correct
10 Correct 39 ms 8540 KB Output is correct
11 Correct 30 ms 8024 KB Output is correct
12 Correct 25 ms 7772 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4560 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 3 ms 4440 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Incorrect 182 ms 8652 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4556 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 116 ms 13280 KB Output is correct
12 Correct 115 ms 13272 KB Output is correct
13 Correct 102 ms 11108 KB Output is correct
14 Incorrect 195 ms 11608 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 58 ms 9556 KB Output is correct
10 Correct 39 ms 8540 KB Output is correct
11 Correct 30 ms 8024 KB Output is correct
12 Correct 25 ms 7772 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 1 ms 4560 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 3 ms 4440 KB Output is correct
19 Correct 3 ms 4700 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Incorrect 182 ms 8652 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4556 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4696 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4440 KB Output is correct
10 Correct 2 ms 4444 KB Output is correct
11 Correct 116 ms 13280 KB Output is correct
12 Correct 115 ms 13272 KB Output is correct
13 Correct 102 ms 11108 KB Output is correct
14 Incorrect 195 ms 11608 KB Output isn't correct
15 Halted 0 ms 0 KB -