답안 #1018829

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1018829 2024-07-10T10:04:34 Z vjudge1 Self Study (JOI22_ho_t2) C++17
0 / 100
88 ms 5148 KB
#include "bits/stdc++.h"
#define int long long
using namespace std;

template <typename _T>
bool chmin(_T &a, const _T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename _T>
bool chmax(_T &a, const _T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for(auto &x : a){
	    cin >> x;
	} 
	vector<int> b(n);
	for(auto &x : b){
	    cin >> x;
	} 
	for(int i = 0; i < n; i++){
	    a[i] = max(a[i], b[i]);
	} 
	auto check = [&](int val){
		int cnt = 0;
		for(int i = 0; i < n; i++){
			if(a[i] * m >= val){
			    cnt += ((val - 1) / a[i] + 1);
			} 
			else{
			    cnt += (m + (val - m * a[i] - 1) / b[i] + 1);
			}
		}
		if(cnt <= m * n){
		    return true;
		}
		else return false;
	};
	
	long long l = 0, r = 2e18;
	while(l + 1 != r){
		int mid = (l + r) / 2;
		if(check(mid)){
		    l = mid;
		}
		else r = mid;
	}
	cout << l << "\n";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 86 ms 5148 KB Output is correct
12 Correct 88 ms 5108 KB Output is correct
13 Correct 77 ms 5136 KB Output is correct
14 Incorrect 86 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 45 ms 2660 KB Output is correct
10 Correct 31 ms 1884 KB Output is correct
11 Correct 24 ms 1628 KB Output is correct
12 Correct 16 ms 1412 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 86 ms 5148 KB Output is correct
12 Correct 88 ms 5108 KB Output is correct
13 Correct 77 ms 5136 KB Output is correct
14 Incorrect 86 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 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 1 ms 600 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 45 ms 2660 KB Output is correct
10 Correct 31 ms 1884 KB Output is correct
11 Correct 24 ms 1628 KB Output is correct
12 Correct 16 ms 1412 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Incorrect 2 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 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 0 ms 348 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 86 ms 5148 KB Output is correct
12 Correct 88 ms 5108 KB Output is correct
13 Correct 77 ms 5136 KB Output is correct
14 Incorrect 86 ms 4956 KB Output isn't correct
15 Halted 0 ms 0 KB -