답안 #530290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530290 2022-02-25T02:06:28 Z yungyao Self Study (JOI22_ho_t2) C++17
100 / 100
248 ms 10596 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){
	__int128 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 = 1, 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 400 KB Output is correct
11 Correct 187 ms 4996 KB Output is correct
12 Correct 174 ms 4968 KB Output is correct
13 Correct 158 ms 4992 KB Output is correct
14 Correct 202 ms 4988 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 205 ms 6112 KB Output is correct
17 Correct 177 ms 8656 KB Output is correct
18 Correct 177 ms 8424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 205 ms 6112 KB Output is correct
3 Correct 177 ms 8656 KB Output is correct
4 Correct 177 ms 8424 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 79 ms 2592 KB Output is correct
14 Correct 54 ms 1872 KB Output is correct
15 Correct 42 ms 1484 KB Output is correct
16 Correct 34 ms 1260 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 3 ms 332 KB Output is correct
23 Correct 4 ms 440 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 400 KB Output is correct
11 Correct 187 ms 4996 KB Output is correct
12 Correct 174 ms 4968 KB Output is correct
13 Correct 158 ms 4992 KB Output is correct
14 Correct 202 ms 4988 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 79 ms 2592 KB Output is correct
24 Correct 54 ms 1872 KB Output is correct
25 Correct 42 ms 1484 KB Output is correct
26 Correct 34 ms 1260 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 4 ms 440 KB Output is correct
34 Correct 1 ms 204 KB Output is correct
35 Correct 205 ms 6112 KB Output is correct
36 Correct 177 ms 8656 KB Output is correct
37 Correct 177 ms 8424 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 0 ms 204 KB Output is correct
43 Correct 1 ms 316 KB Output is correct
44 Correct 1 ms 316 KB Output is correct
45 Correct 4 ms 432 KB Output is correct
46 Correct 5 ms 588 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 31 ms 1904 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 5 ms 420 KB Output is correct
52 Correct 1 ms 204 KB Output is correct
53 Correct 1 ms 204 KB Output is correct
54 Correct 1 ms 332 KB Output is correct
55 Correct 88 ms 4976 KB Output is correct
56 Correct 55 ms 2824 KB Output is correct
57 Correct 76 ms 2852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 79 ms 2592 KB Output is correct
10 Correct 54 ms 1872 KB Output is correct
11 Correct 42 ms 1484 KB Output is correct
12 Correct 34 ms 1260 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 3 ms 332 KB Output is correct
19 Correct 4 ms 440 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 205 ms 6112 KB Output is correct
22 Correct 177 ms 8656 KB Output is correct
23 Correct 177 ms 8424 KB Output is correct
24 Correct 34 ms 1608 KB Output is correct
25 Correct 87 ms 4120 KB Output is correct
26 Correct 19 ms 1152 KB Output is correct
27 Correct 174 ms 8900 KB Output is correct
28 Correct 162 ms 10208 KB Output is correct
29 Correct 163 ms 8808 KB Output is correct
30 Correct 184 ms 7976 KB Output is correct
31 Correct 212 ms 8512 KB Output is correct
32 Correct 214 ms 5764 KB Output is correct
33 Correct 248 ms 7960 KB Output is correct
34 Correct 214 ms 5488 KB Output is correct
# 결과 실행 시간 메모리 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 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 400 KB Output is correct
11 Correct 187 ms 4996 KB Output is correct
12 Correct 174 ms 4968 KB Output is correct
13 Correct 158 ms 4992 KB Output is correct
14 Correct 202 ms 4988 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 0 ms 204 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 0 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 79 ms 2592 KB Output is correct
24 Correct 54 ms 1872 KB Output is correct
25 Correct 42 ms 1484 KB Output is correct
26 Correct 34 ms 1260 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 0 ms 204 KB Output is correct
29 Correct 0 ms 204 KB Output is correct
30 Correct 0 ms 204 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 3 ms 332 KB Output is correct
33 Correct 4 ms 440 KB Output is correct
34 Correct 1 ms 320 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 1 ms 204 KB Output is correct
37 Correct 1 ms 204 KB Output is correct
38 Correct 0 ms 204 KB Output is correct
39 Correct 1 ms 316 KB Output is correct
40 Correct 1 ms 316 KB Output is correct
41 Correct 4 ms 432 KB Output is correct
42 Correct 5 ms 588 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 31 ms 1904 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 5 ms 420 KB Output is correct
48 Correct 1 ms 204 KB Output is correct
49 Correct 1 ms 204 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 88 ms 4976 KB Output is correct
52 Correct 55 ms 2824 KB Output is correct
53 Correct 76 ms 2852 KB Output is correct
54 Correct 34 ms 1608 KB Output is correct
55 Correct 87 ms 4120 KB Output is correct
56 Correct 19 ms 1152 KB Output is correct
57 Correct 174 ms 8900 KB Output is correct
58 Correct 162 ms 10208 KB Output is correct
59 Correct 163 ms 8808 KB Output is correct
60 Correct 184 ms 7976 KB Output is correct
61 Correct 212 ms 8512 KB Output is correct
62 Correct 214 ms 5764 KB Output is correct
63 Correct 248 ms 7960 KB Output is correct
64 Correct 214 ms 5488 KB Output is correct
65 Correct 1 ms 204 KB Output is correct
66 Correct 205 ms 6112 KB Output is correct
67 Correct 177 ms 8656 KB Output is correct
68 Correct 177 ms 8424 KB Output is correct
69 Correct 24 ms 1260 KB Output is correct
70 Correct 6 ms 588 KB Output is correct
71 Correct 0 ms 204 KB Output is correct
72 Correct 35 ms 1348 KB Output is correct
73 Correct 10 ms 588 KB Output is correct
74 Correct 1 ms 360 KB Output is correct
75 Correct 173 ms 7804 KB Output is correct
76 Correct 177 ms 9900 KB Output is correct
77 Correct 182 ms 10204 KB Output is correct
78 Correct 190 ms 9528 KB Output is correct
79 Correct 224 ms 10392 KB Output is correct
80 Correct 226 ms 10596 KB Output is correct
81 Correct 224 ms 8660 KB Output is correct
82 Correct 222 ms 8672 KB Output is correct