Submission #923427

# Submission time Handle Problem Language Result Execution time Memory
923427 2024-02-07T08:22:39 Z dreamoon Self Study (JOI22_ho_t2) C++14
0 / 100
0 ms 348 KB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;
 
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int>a(n), b(n);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;
	
	int l = -1, r = (long long)(1e18) + 5, mid;
    cout << r << endl;
	while (l + 1 < r) {
		mid = (l + r) / 2;
		int need = 0;
		for (int i = 0 ; i < n ; i++) {
			if (a[i] > b[i]) {
				if (mid > a[i] * m) need += m + (mid - a[i] * m) / b[i] + ((mid - a[i] * m) % b[i] != 0ll ? 1ll : 0ll);
				else need += (mid / a[i]) + (mid % a[i] != 0ll ? 1ll : 0ll);
			} else {
				need += (mid / b[i]) + (mid % b[i] != 0ll ? 1ll : 0ll);
			}
		}
		if (need <= n * m) {
			l = mid;
			//cout << l << " " << need << "\n";
		} else {
			r = mid;
		}
	}
	cout << l << "\n";
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -