답안 #530285

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530285 2022-02-25T01:55:21 Z yungyao Self Study (JOI22_ho_t2) C++17
0 / 100
305 ms 10632 KB
using namespace std;
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define iter(x) x.begin(),x.end()
#define REP(n) for (int __=n;__--;)
#define REP0(i,n) for (int i=0;i<n;++i)
#define REP1(i,n) for (int i=1;i<=n;++i)

const int maxn = 3e5+10, mod = 0;
const LL inf = 0;

int n;
LL m, a[maxn], b[maxn];
bool bs(LL t){
	LL cnt = 0;
	REP1(i, n){
		if (b[i] > a[i]) cnt += m - (t + b[i] - 1) / b[i];
		else if (a[i] * m >= t) cnt += m - (t + a[i] - 1) / a[i];
		else cnt -= (t - a[i] * m + b[i] - 1) / b[i];
	}
	return cnt >= 0;
}

void solve(){

	cin >> n >> m;
	REP1(i, n) cin >> a[i];
	REP1(i, n) cin >> b[i];
	LL LB = 0, RB = 1e18;
	while (LB != RB){
		LL m = (LB + RB + 1) / 2;
		if (bs(m)) LB = m;
		else RB = m-1;
	}
	cout << LB;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);

	solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 170 ms 10632 KB Output is correct
12 Correct 164 ms 10564 KB Output is correct
13 Correct 157 ms 7648 KB Output is correct
14 Incorrect 305 ms 8792 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 85 ms 5444 KB Output is correct
10 Correct 55 ms 3192 KB Output is correct
11 Correct 41 ms 2584 KB Output is correct
12 Correct 34 ms 2116 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 316 KB Output is correct
18 Incorrect 5 ms 332 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 170 ms 10632 KB Output is correct
12 Correct 164 ms 10564 KB Output is correct
13 Correct 157 ms 7648 KB Output is correct
14 Incorrect 305 ms 8792 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 320 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 0 ms 316 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 85 ms 5444 KB Output is correct
10 Correct 55 ms 3192 KB Output is correct
11 Correct 41 ms 2584 KB Output is correct
12 Correct 34 ms 2116 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 0 ms 316 KB Output is correct
18 Incorrect 5 ms 332 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 324 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 3 ms 460 KB Output is correct
11 Correct 170 ms 10632 KB Output is correct
12 Correct 164 ms 10564 KB Output is correct
13 Correct 157 ms 7648 KB Output is correct
14 Incorrect 305 ms 8792 KB Output isn't correct
15 Halted 0 ms 0 KB -