제출 #526437

#제출 시각아이디문제언어결과실행 시간메모리
526437sidonSelf Study (JOI22_ho_t2)C++17
100 / 100
388 ms6556 KiB
#include <bits/stdc++.h>
using namespace std;
#define int __int128
#define i64 int64_t

const int Z = 3e5, INF = 1e18;

i64 N, M, A[Z], B[Z];

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> M;

	for(int i = 0; i < N; ++i) cin >> A[i];
	for(int i = 0; i < N; ++i) cin >> B[i];

	for(int i = 0; i < N; ++i)
		A[i] = max(A[i], B[i]);

	int ans = 0;

	for(int add = 1LL<<62; add /= 2; ) {
		int x = ans + add;

		int free = 0;

		for(int i = 0; i < N; ++i) {
			int a_req = (x + A[i] - 1) / A[i];

			if(a_req <= M)
				free += M - a_req;
			else {
				int req = x - M * A[i];

				int b_req = (req + B[i] - 1) / B[i];
				free -= b_req;
			}
		}

		if(free >= 0) ans += add;
	}

	cout << (int64_t)ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...