Submission #863834

# Submission time Handle Problem Language Result Execution time Memory
863834 2023-10-21T08:18:14 Z phoenix0423 Self Study (JOI22_ho_t2) C++17
100 / 100
221 ms 11092 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;
const ll INF = 8e18;

int main(void){
	fastio;
	ll n, m;
	cin>>n>>m;
	vector<ll> a(n), b(n);
	for(int i = 0; i < n; i++) cin>>a[i];
	for(int i = 0; i < n; i++) cin>>b[i];
	ll l = 0, r = INF;
	while(l + 1 < r){
		ll mid = (l + r) / 2;
		vector<ll> have(n, 0);
		ll nd = 0;
		for(int i = 0; i < n; i++){
			if(a[i] <= b[i]){
				nd += (mid - 1) / b[i] + 1;
			}
			else if(a[i] * m >= mid){
				nd += (mid - 1) / a[i] + 1;
			}
			else{
				nd += m + (mid - a[i] * m - 1) / b[i] + 1;
			}
			if(nd > n * m) break;
		}
		if(nd > n * m) r = mid;
		else l = mid;
	}
	cout<<l<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 7444 KB Output is correct
12 Correct 97 ms 7720 KB Output is correct
13 Correct 71 ms 7488 KB Output is correct
14 Correct 59 ms 7448 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 36 ms 7476 KB Output is correct
17 Correct 94 ms 7468 KB Output is correct
18 Correct 87 ms 7720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 36 ms 7476 KB Output is correct
3 Correct 94 ms 7468 KB Output is correct
4 Correct 87 ms 7720 KB Output is correct
5 Correct 0 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 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 45 ms 3944 KB Output is correct
14 Correct 30 ms 2976 KB Output is correct
15 Correct 22 ms 2140 KB Output is correct
16 Correct 20 ms 1880 KB Output is correct
17 Correct 1 ms 500 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 7444 KB Output is correct
12 Correct 97 ms 7720 KB Output is correct
13 Correct 71 ms 7488 KB Output is correct
14 Correct 59 ms 7448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 45 ms 3944 KB Output is correct
24 Correct 30 ms 2976 KB Output is correct
25 Correct 22 ms 2140 KB Output is correct
26 Correct 20 ms 1880 KB Output is correct
27 Correct 1 ms 500 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 36 ms 7476 KB Output is correct
36 Correct 94 ms 7468 KB Output is correct
37 Correct 87 ms 7720 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 1 ms 452 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 464 KB Output is correct
46 Correct 3 ms 840 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 19 ms 2396 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 49 ms 5708 KB Output is correct
56 Correct 27 ms 3408 KB Output is correct
57 Correct 22 ms 3420 KB Output is correct
# Verdict Execution time Memory 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 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 45 ms 3944 KB Output is correct
10 Correct 30 ms 2976 KB Output is correct
11 Correct 22 ms 2140 KB Output is correct
12 Correct 20 ms 1880 KB Output is correct
13 Correct 1 ms 500 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 760 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 36 ms 7476 KB Output is correct
22 Correct 94 ms 7468 KB Output is correct
23 Correct 87 ms 7720 KB Output is correct
24 Correct 27 ms 2284 KB Output is correct
25 Correct 64 ms 4948 KB Output is correct
26 Correct 11 ms 1636 KB Output is correct
27 Correct 89 ms 10560 KB Output is correct
28 Correct 90 ms 10564 KB Output is correct
29 Correct 93 ms 10560 KB Output is correct
30 Correct 119 ms 10480 KB Output is correct
31 Correct 187 ms 10536 KB Output is correct
32 Correct 112 ms 8216 KB Output is correct
33 Correct 221 ms 11092 KB Output is correct
34 Correct 115 ms 8216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 90 ms 7444 KB Output is correct
12 Correct 97 ms 7720 KB Output is correct
13 Correct 71 ms 7488 KB Output is correct
14 Correct 59 ms 7448 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 45 ms 3944 KB Output is correct
24 Correct 30 ms 2976 KB Output is correct
25 Correct 22 ms 2140 KB Output is correct
26 Correct 20 ms 1880 KB Output is correct
27 Correct 1 ms 500 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 760 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 1 ms 452 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 464 KB Output is correct
42 Correct 3 ms 840 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 19 ms 2396 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 2 ms 604 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 49 ms 5708 KB Output is correct
52 Correct 27 ms 3408 KB Output is correct
53 Correct 22 ms 3420 KB Output is correct
54 Correct 27 ms 2284 KB Output is correct
55 Correct 64 ms 4948 KB Output is correct
56 Correct 11 ms 1636 KB Output is correct
57 Correct 89 ms 10560 KB Output is correct
58 Correct 90 ms 10564 KB Output is correct
59 Correct 93 ms 10560 KB Output is correct
60 Correct 119 ms 10480 KB Output is correct
61 Correct 187 ms 10536 KB Output is correct
62 Correct 112 ms 8216 KB Output is correct
63 Correct 221 ms 11092 KB Output is correct
64 Correct 115 ms 8216 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 36 ms 7476 KB Output is correct
67 Correct 94 ms 7468 KB Output is correct
68 Correct 87 ms 7720 KB Output is correct
69 Correct 19 ms 1624 KB Output is correct
70 Correct 5 ms 604 KB Output is correct
71 Correct 0 ms 348 KB Output is correct
72 Correct 29 ms 2200 KB Output is correct
73 Correct 6 ms 860 KB Output is correct
74 Correct 1 ms 472 KB Output is correct
75 Correct 101 ms 10516 KB Output is correct
76 Correct 126 ms 10536 KB Output is correct
77 Correct 123 ms 10512 KB Output is correct
78 Correct 142 ms 10560 KB Output is correct
79 Correct 195 ms 10732 KB Output is correct
80 Correct 207 ms 10400 KB Output is correct
81 Correct 208 ms 9496 KB Output is correct
82 Correct 102 ms 9512 KB Output is correct