답안 #681464

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
681464 2023-01-13T06:38:20 Z sudheerays123 Self Study (JOI22_ho_t2) C++17
100 / 100
247 ms 10820 KB
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
const ll N = 3e5+5 , INF = 1e18 , MOD = 1e9+7;

vector<ll> a(N),b(N);
ll n,m;

bool check(ll x){

	ll cnt = 0;

	for(ll i = 1; i <= n; i++){
		ll maxi = max(a[i],b[i]);
		if(maxi*m < x){
			cnt += m;
			ll cur = x-(maxi*m);
			cnt += ((cur+b[i]-1)/b[i]);
		}
		else cnt += ((x+maxi-1)/maxi);
		
		if(cnt > (n*m)) return false;
	}

	return (cnt <= (n*m));
}

void solve(){

	cin >> n >> m;
	for(ll i = 1; i <= n; i++) cin >> a[i];
	for(ll i = 1; i <= n; i++) cin >> b[i];

	ll low = 1 , high = 1e18;
	ll ans;

	while(low <= high){
		ll mid = (low+high)/2;

		if(check(mid)){
			ans = mid;
			low = mid+1;
		}
		else high = mid-1;
	}

	cout << ans;
}

int main(){

	fast;

	ll tc = 1;
	// cin >> tc;
	while(tc--) solve();

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 3 ms 5032 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 110 ms 10772 KB Output is correct
12 Correct 100 ms 10768 KB Output is correct
13 Correct 87 ms 8828 KB Output is correct
14 Correct 79 ms 8840 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 32 ms 5132 KB Output is correct
17 Correct 105 ms 5136 KB Output is correct
18 Correct 95 ms 5060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 32 ms 5132 KB Output is correct
3 Correct 105 ms 5136 KB Output is correct
4 Correct 95 ms 5060 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 3 ms 4948 KB Output is correct
7 Correct 3 ms 4948 KB Output is correct
8 Correct 3 ms 4948 KB Output is correct
9 Correct 3 ms 4948 KB Output is correct
10 Correct 2 ms 4948 KB Output is correct
11 Correct 2 ms 4948 KB Output is correct
12 Correct 2 ms 4948 KB Output is correct
13 Correct 50 ms 5216 KB Output is correct
14 Correct 39 ms 5212 KB Output is correct
15 Correct 28 ms 5204 KB Output is correct
16 Correct 25 ms 5124 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 2 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 3 ms 4948 KB Output is correct
23 Correct 5 ms 5076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 3 ms 5032 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 110 ms 10772 KB Output is correct
12 Correct 100 ms 10768 KB Output is correct
13 Correct 87 ms 8828 KB Output is correct
14 Correct 79 ms 8840 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 50 ms 5216 KB Output is correct
24 Correct 39 ms 5212 KB Output is correct
25 Correct 28 ms 5204 KB Output is correct
26 Correct 25 ms 5124 KB Output is correct
27 Correct 2 ms 4948 KB Output is correct
28 Correct 2 ms 4948 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Correct 2 ms 4948 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 2 ms 4948 KB Output is correct
35 Correct 32 ms 5132 KB Output is correct
36 Correct 105 ms 5136 KB Output is correct
37 Correct 95 ms 5060 KB Output is correct
38 Correct 3 ms 4948 KB Output is correct
39 Correct 4 ms 4948 KB Output is correct
40 Correct 2 ms 4948 KB Output is correct
41 Correct 3 ms 4948 KB Output is correct
42 Correct 2 ms 4948 KB Output is correct
43 Correct 2 ms 5032 KB Output is correct
44 Correct 2 ms 5032 KB Output is correct
45 Correct 4 ms 5040 KB Output is correct
46 Correct 5 ms 5116 KB Output is correct
47 Correct 3 ms 5048 KB Output is correct
48 Correct 19 ms 6028 KB Output is correct
49 Correct 2 ms 5032 KB Output is correct
50 Correct 2 ms 4948 KB Output is correct
51 Correct 4 ms 5076 KB Output is correct
52 Correct 2 ms 4948 KB Output is correct
53 Correct 3 ms 4948 KB Output is correct
54 Correct 2 ms 4948 KB Output is correct
55 Correct 50 ms 7824 KB Output is correct
56 Correct 33 ms 6228 KB Output is correct
57 Correct 27 ms 6296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 4948 KB Output is correct
4 Correct 3 ms 4948 KB Output is correct
5 Correct 3 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 2 ms 4948 KB Output is correct
9 Correct 50 ms 5216 KB Output is correct
10 Correct 39 ms 5212 KB Output is correct
11 Correct 28 ms 5204 KB Output is correct
12 Correct 25 ms 5124 KB Output is correct
13 Correct 2 ms 4948 KB Output is correct
14 Correct 2 ms 4948 KB Output is correct
15 Correct 3 ms 4948 KB Output is correct
16 Correct 2 ms 4948 KB Output is correct
17 Correct 2 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 5 ms 5076 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 32 ms 5132 KB Output is correct
22 Correct 105 ms 5136 KB Output is correct
23 Correct 95 ms 5060 KB Output is correct
24 Correct 31 ms 5076 KB Output is correct
25 Correct 69 ms 5076 KB Output is correct
26 Correct 14 ms 5040 KB Output is correct
27 Correct 97 ms 5136 KB Output is correct
28 Correct 101 ms 5076 KB Output is correct
29 Correct 100 ms 5156 KB Output is correct
30 Correct 118 ms 5040 KB Output is correct
31 Correct 197 ms 5148 KB Output is correct
32 Correct 102 ms 5076 KB Output is correct
33 Correct 247 ms 5076 KB Output is correct
34 Correct 96 ms 5116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4948 KB Output is correct
2 Correct 2 ms 4948 KB Output is correct
3 Correct 2 ms 4948 KB Output is correct
4 Correct 2 ms 4948 KB Output is correct
5 Correct 2 ms 4948 KB Output is correct
6 Correct 2 ms 4948 KB Output is correct
7 Correct 2 ms 4948 KB Output is correct
8 Correct 3 ms 5032 KB Output is correct
9 Correct 2 ms 4948 KB Output is correct
10 Correct 4 ms 5076 KB Output is correct
11 Correct 110 ms 10772 KB Output is correct
12 Correct 100 ms 10768 KB Output is correct
13 Correct 87 ms 8828 KB Output is correct
14 Correct 79 ms 8840 KB Output is correct
15 Correct 2 ms 4948 KB Output is correct
16 Correct 3 ms 4948 KB Output is correct
17 Correct 3 ms 4948 KB Output is correct
18 Correct 3 ms 4948 KB Output is correct
19 Correct 3 ms 4948 KB Output is correct
20 Correct 2 ms 4948 KB Output is correct
21 Correct 2 ms 4948 KB Output is correct
22 Correct 2 ms 4948 KB Output is correct
23 Correct 50 ms 5216 KB Output is correct
24 Correct 39 ms 5212 KB Output is correct
25 Correct 28 ms 5204 KB Output is correct
26 Correct 25 ms 5124 KB Output is correct
27 Correct 2 ms 4948 KB Output is correct
28 Correct 2 ms 4948 KB Output is correct
29 Correct 3 ms 4948 KB Output is correct
30 Correct 2 ms 4948 KB Output is correct
31 Correct 2 ms 4948 KB Output is correct
32 Correct 3 ms 4948 KB Output is correct
33 Correct 5 ms 5076 KB Output is correct
34 Correct 3 ms 4948 KB Output is correct
35 Correct 4 ms 4948 KB Output is correct
36 Correct 2 ms 4948 KB Output is correct
37 Correct 3 ms 4948 KB Output is correct
38 Correct 2 ms 4948 KB Output is correct
39 Correct 2 ms 5032 KB Output is correct
40 Correct 2 ms 5032 KB Output is correct
41 Correct 4 ms 5040 KB Output is correct
42 Correct 5 ms 5116 KB Output is correct
43 Correct 3 ms 5048 KB Output is correct
44 Correct 19 ms 6028 KB Output is correct
45 Correct 2 ms 5032 KB Output is correct
46 Correct 2 ms 4948 KB Output is correct
47 Correct 4 ms 5076 KB Output is correct
48 Correct 2 ms 4948 KB Output is correct
49 Correct 3 ms 4948 KB Output is correct
50 Correct 2 ms 4948 KB Output is correct
51 Correct 50 ms 7824 KB Output is correct
52 Correct 33 ms 6228 KB Output is correct
53 Correct 27 ms 6296 KB Output is correct
54 Correct 31 ms 5076 KB Output is correct
55 Correct 69 ms 5076 KB Output is correct
56 Correct 14 ms 5040 KB Output is correct
57 Correct 97 ms 5136 KB Output is correct
58 Correct 101 ms 5076 KB Output is correct
59 Correct 100 ms 5156 KB Output is correct
60 Correct 118 ms 5040 KB Output is correct
61 Correct 197 ms 5148 KB Output is correct
62 Correct 102 ms 5076 KB Output is correct
63 Correct 247 ms 5076 KB Output is correct
64 Correct 96 ms 5116 KB Output is correct
65 Correct 2 ms 4948 KB Output is correct
66 Correct 32 ms 5132 KB Output is correct
67 Correct 105 ms 5136 KB Output is correct
68 Correct 95 ms 5060 KB Output is correct
69 Correct 22 ms 5656 KB Output is correct
70 Correct 8 ms 5168 KB Output is correct
71 Correct 2 ms 4948 KB Output is correct
72 Correct 33 ms 5844 KB Output is correct
73 Correct 8 ms 5204 KB Output is correct
74 Correct 3 ms 5044 KB Output is correct
75 Correct 102 ms 10820 KB Output is correct
76 Correct 141 ms 10820 KB Output is correct
77 Correct 121 ms 10808 KB Output is correct
78 Correct 150 ms 10820 KB Output is correct
79 Correct 212 ms 10700 KB Output is correct
80 Correct 215 ms 10820 KB Output is correct
81 Correct 221 ms 8844 KB Output is correct
82 Correct 223 ms 8836 KB Output is correct