답안 #1018800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018800 2024-07-10T09:52:16 Z Bilal_Coder Self Study (JOI22_ho_t2) C++17
0 / 100
1000 ms 348 KB
#include "bits/stdc++.h"
using namespace std;
#define int long long 
/*
▀█████████▄   ▄█   ▄█          ▄████████  ▄█        ▄████████  ▄██████▄  ████████▄     ▄████████    ▄████████ 
  ███    ███ ███  ███         ███    ███ ███       ███    ███ ███    ███ ███   ▀███   ███    ███   ███    ███ 
  ███    ███ ███▌ ███         ███    ███ ███       ███    █▀  ███    ███ ███    ███   ███    █▀    ███    ███ 
 ▄███▄▄▄██▀  ███▌ ███         ███    ███ ███       ███        ███    ███ ███    ███  ▄███▄▄▄      ▄███▄▄▄▄██▀ 
▀▀███▀▀▀██▄  ███▌ ███       ▀███████████ ███       ███        ███    ███ ███    ███ ▀▀███▀▀▀     ▀▀███▀▀▀▀▀   
  ███    ██▄ ███  ███         ███    ███ ███       ███    █▄  ███    ███ ███    ███   ███    █▄  ▀███████████ 
  ███    ███ ███  ███▌    ▄   ███    ███ ███▌    ▄ ███    ███ ███    ███ ███   ▄███   ███    ███   ███    ███ 
▄█████████▀  █▀   █████▄▄██   ███    █▀  █████▄▄██ ████████▀   ▀██████▀  ████████▀    ██████████   ███    ███ 
                  ▀                      ▀                                                         ███    ███ 
*/
template<class T> bool setmax(T& a, const T& b){ 
	return b < a ? a = b, 1 : 0; 
}
template<class T> bool setmin(T& a, const T& b){ 
	return a < b ? a = b, 1 : 0; 
} 
signed main()
{
	int n , m;
	cin >> n >> m;
	vector<int> a(n) , b(n);
	for (auto & x : a)
		cin >> x;
	for (auto & x : b)
		cin >> x;
	auto check = [&](int p){
		int t = 0;
		for (int i = 0; i < n; i++){
			if (b[i] > a[i])
				t += (p + b[i] - 1) / b[i];
			else {
				if (a[i] * 1ll * m >= p)
					t += (p + a[i] - 1) / a[i];
				else 
					t += m + (p - a[i] * 1ll * m + b[i] - 1) / b[i];
			}
		}
		if (t <= n * 1ll * m)
			return true;
		return false;
	};
	int l = 0 , r = 1e18 + 1;
	while(l < r){
		int m = (l + r) >> 1;
		if (check(m))
			l = m;
		else r = m - 1;
	}
	cout << l << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1016 ms 344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1049 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -