답안 #864789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
864789 2023-10-23T15:36:50 Z serifefedartar Self Study (JOI22_ho_t2) C++17
0 / 100
272 ms 8216 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0);
#define s second
#define f first
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll LOGN = 20; 
const ll MAXN = 3e5 + 100;
#define int long long

vector<ll> A, B;
ll N, M;
bool check(ll x) {
	ll need = 0;
	for (int i = 1; i <= N; i++) {
		if (M * A[i] >= x)
			need += (x + A[i] - 1) / A[i];
		else
			need += M + (x - A[i] * M + B[i] - 1) / B[i];
	}
	return (need <= N * M);
}

signed main() {
	fast
	cin >> N >> M;

	A = vector<ll>(N+1);
	B = vector<ll>(N+1);
	for (int i = 1; i <= N; i++)
		cin >> A[i];
	for (int i = 1; i <= N; i++)
		cin >> B[i];
	for (int i = 1; i <= N; i++)
		A[i] = max(A[i], B[i]);

	ll L = 0;
	ll R = 2 * 1e18;
	ll ans = -1;
	while (L <= R) {
		ll mid = L + (R-L)/2;
		if (check(mid)) {
			L = mid + 1;
			ans = mid;
		} else
			R = mid - 1;
	}
	cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 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 2 ms 616 KB Output is correct
11 Correct 146 ms 8216 KB Output is correct
12 Correct 152 ms 8212 KB Output is correct
13 Correct 135 ms 7064 KB Output is correct
14 Incorrect 272 ms 6996 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 78 ms 4584 KB Output is correct
10 Correct 50 ms 3160 KB Output is correct
11 Correct 37 ms 2652 KB Output is correct
12 Correct 30 ms 2384 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 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 2 ms 616 KB Output is correct
11 Correct 146 ms 8216 KB Output is correct
12 Correct 152 ms 8212 KB Output is correct
13 Correct 135 ms 7064 KB Output is correct
14 Incorrect 272 ms 6996 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 78 ms 4584 KB Output is correct
10 Correct 50 ms 3160 KB Output is correct
11 Correct 37 ms 2652 KB Output is correct
12 Correct 30 ms 2384 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 456 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 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 348 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 2 ms 616 KB Output is correct
11 Correct 146 ms 8216 KB Output is correct
12 Correct 152 ms 8212 KB Output is correct
13 Correct 135 ms 7064 KB Output is correct
14 Incorrect 272 ms 6996 KB Output isn't correct
15 Halted 0 ms 0 KB -