답안 #842187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842187 2023-09-02T13:46:03 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
352 ms 7384 KB
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {return o << '(' << p.first << ", " << p.second << ')';}
template<size_t Index = 0, typename... Types>
ostream& printTupleElements(ostream& o, const tuple<Types...>& t) {if constexpr (Index < sizeof...(Types)){if(Index > 0){o << ", ";}o << get<Index>(t);printTupleElements<Index + 1>(o, t);}return o;}
template<typename... Types>
ostream& operator<<(ostream& o, const tuple<Types...>& t){o << "(";printTupleElements(o, t);return o << ")";}
template<class T>
auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o){o << '{';bool first = true;for (const auto& e : x){if (!first){o << ", ";}o << e;first = false;} return o << '}';}
#define DEBUG
#ifdef DEBUG
#define fastio()
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#define check(x) if (!(x)) { cerr << "Check failed: " << #x << " in line " << __LINE__ << endl; exit(1); }
#else
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0);
#define debug(...)
#define check(x) 
#endif
typedef long long ll;
#define pi pair<int, int>
#define pl pair<ll, ll>
#define st first
#define nd second
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
constexpr int LIM = 3e5;
ll A[LIM + 10];
ll B[LIM + 10];
bool czy(ll x, int n, ll m) {
	ll wol = 0;
	for(int i = 1; i <= n; i++) {
		if(A[i] * m >= x) {
			wol += m - ((x + A[i] - 1) / A[i]);
		}
		else {
			wol -= ((x - A[i] * m) + B[i] - 1) / B[i];
		}
	}
	return wol >= 0;
}
void solve() {
	//ifstream cin("nazwa.in");
	//ofstream cout("nazwa.out");
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> A[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> B[i];
		A[i] = max(A[i], B[i]);
	}
	ll l = 0;
	ll r = 1e18;
	while(l < r) {
		ll mid = (l + r + 1) / 2;
		if(czy(mid, n, m)) {
			l = mid;
		}
		else {
			r = mid - 1;
		}
	}
	cout << l <<  '\n';
}
int main() {
	fastio();
	int t;
	//cin >> t;
	t = 1;	
	while(t--) {
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2596 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2392 KB Output is correct
11 Correct 302 ms 4948 KB Output is correct
12 Correct 265 ms 5200 KB Output is correct
13 Correct 214 ms 5108 KB Output is correct
14 Incorrect 352 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 134 ms 7384 KB Output is correct
10 Correct 88 ms 6640 KB Output is correct
11 Correct 67 ms 5928 KB Output is correct
12 Correct 53 ms 5724 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 5 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2596 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2392 KB Output is correct
11 Correct 302 ms 4948 KB Output is correct
12 Correct 265 ms 5200 KB Output is correct
13 Correct 214 ms 5108 KB Output is correct
14 Incorrect 352 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2648 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 134 ms 7384 KB Output is correct
10 Correct 88 ms 6640 KB Output is correct
11 Correct 67 ms 5928 KB Output is correct
12 Correct 53 ms 5724 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2648 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Incorrect 5 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2596 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 4 ms 2392 KB Output is correct
11 Correct 302 ms 4948 KB Output is correct
12 Correct 265 ms 5200 KB Output is correct
13 Correct 214 ms 5108 KB Output is correct
14 Incorrect 352 ms 5200 KB Output isn't correct
15 Halted 0 ms 0 KB -