Submission #526418

# Submission time Handle Problem Language Result Execution time Memory
526418 2022-02-14T17:54:28 Z benson1029 Self Study (JOI22_ho_t2) C++14
100 / 100
421 ms 5060 KB
#include<bits/stdc++.h>
using namespace std;

long long n,m;
long long a[300005], b[300005];
long long l, r, mid;

bool check(long long x) {
	long long extra = 0, need = 0;
	for(int i=1; i<=n; i++) {
		if(a[i] > b[i]){ // study in class
			long long needed = (x + a[i] - 1) / a[i];
			if(needed > m) {
				need += (x - a[i] * m + b[i] - 1) / b[i];
				if(need > 1e18) return false;
			} else {
				extra += m - needed;
			}
		} else { // study at any time
			extra += m;
			need += (x + b[i] - 1) / b[i];
			if(need > 1e18) return false;
		}
	}
	if(extra>=need) return true;
	else return false;
}

int main() {
	cin >> n >> m;
	for(int i=1; i<=n; i++) cin >> a[i];
	for(int i=1; i<=n; i++) cin >> b[i];
	l = 0; r = 1e18;
	while(l<r) {
		mid = (l+r+1)/2;
		if(check(mid)) l = mid;
		else r = mid - 1;
	} 
	cout << l << "\n"; 
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 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 1 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 1 ms 204 KB Output is correct
10 Correct 6 ms 332 KB Output is correct
11 Correct 360 ms 4936 KB Output is correct
12 Correct 358 ms 4984 KB Output is correct
13 Correct 266 ms 4972 KB Output is correct
14 Correct 294 ms 4972 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 181 ms 5036 KB Output is correct
17 Correct 332 ms 5008 KB Output is correct
18 Correct 320 ms 4868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 181 ms 5036 KB Output is correct
3 Correct 332 ms 5008 KB Output is correct
4 Correct 320 ms 4868 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 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 1 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 159 ms 2688 KB Output is correct
14 Correct 106 ms 1732 KB Output is correct
15 Correct 80 ms 1456 KB Output is correct
16 Correct 65 ms 1236 KB Output is correct
17 Correct 1 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 1 ms 204 KB Output is correct
22 Correct 5 ms 364 KB Output is correct
23 Correct 7 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 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 1 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 1 ms 204 KB Output is correct
10 Correct 6 ms 332 KB Output is correct
11 Correct 360 ms 4936 KB Output is correct
12 Correct 358 ms 4984 KB Output is correct
13 Correct 266 ms 4972 KB Output is correct
14 Correct 294 ms 4972 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 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 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 159 ms 2688 KB Output is correct
24 Correct 106 ms 1732 KB Output is correct
25 Correct 80 ms 1456 KB Output is correct
26 Correct 65 ms 1236 KB Output is correct
27 Correct 1 ms 204 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 5 ms 364 KB Output is correct
33 Correct 7 ms 372 KB Output is correct
34 Correct 0 ms 204 KB Output is correct
35 Correct 181 ms 5036 KB Output is correct
36 Correct 332 ms 5008 KB Output is correct
37 Correct 320 ms 4868 KB Output is correct
38 Correct 1 ms 236 KB Output is correct
39 Correct 0 ms 204 KB Output is correct
40 Correct 0 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 0 ms 204 KB Output is correct
44 Correct 0 ms 204 KB Output is correct
45 Correct 7 ms 332 KB Output is correct
46 Correct 11 ms 440 KB Output is correct
47 Correct 1 ms 204 KB Output is correct
48 Correct 64 ms 972 KB Output is correct
49 Correct 0 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 8 ms 372 KB Output is correct
52 Correct 0 ms 204 KB Output is correct
53 Correct 2 ms 204 KB Output is correct
54 Correct 1 ms 204 KB Output is correct
55 Correct 185 ms 2584 KB Output is correct
56 Correct 103 ms 1812 KB Output is correct
57 Correct 107 ms 1832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 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 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 159 ms 2688 KB Output is correct
10 Correct 106 ms 1732 KB Output is correct
11 Correct 80 ms 1456 KB Output is correct
12 Correct 65 ms 1236 KB Output is correct
13 Correct 1 ms 204 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 5 ms 364 KB Output is correct
19 Correct 7 ms 372 KB Output is correct
20 Correct 0 ms 204 KB Output is correct
21 Correct 181 ms 5036 KB Output is correct
22 Correct 332 ms 5008 KB Output is correct
23 Correct 320 ms 4868 KB Output is correct
24 Correct 56 ms 972 KB Output is correct
25 Correct 167 ms 2336 KB Output is correct
26 Correct 43 ms 688 KB Output is correct
27 Correct 320 ms 4968 KB Output is correct
28 Correct 327 ms 4868 KB Output is correct
29 Correct 316 ms 4848 KB Output is correct
30 Correct 354 ms 4916 KB Output is correct
31 Correct 371 ms 5028 KB Output is correct
32 Correct 200 ms 5060 KB Output is correct
33 Correct 392 ms 4852 KB Output is correct
34 Correct 201 ms 4968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 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 1 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 1 ms 204 KB Output is correct
10 Correct 6 ms 332 KB Output is correct
11 Correct 360 ms 4936 KB Output is correct
12 Correct 358 ms 4984 KB Output is correct
13 Correct 266 ms 4972 KB Output is correct
14 Correct 294 ms 4972 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 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 1 ms 204 KB Output is correct
22 Correct 0 ms 204 KB Output is correct
23 Correct 159 ms 2688 KB Output is correct
24 Correct 106 ms 1732 KB Output is correct
25 Correct 80 ms 1456 KB Output is correct
26 Correct 65 ms 1236 KB Output is correct
27 Correct 1 ms 204 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 5 ms 364 KB Output is correct
33 Correct 7 ms 372 KB Output is correct
34 Correct 1 ms 236 KB Output is correct
35 Correct 0 ms 204 KB Output is correct
36 Correct 0 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 0 ms 204 KB Output is correct
40 Correct 0 ms 204 KB Output is correct
41 Correct 7 ms 332 KB Output is correct
42 Correct 11 ms 440 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 64 ms 972 KB Output is correct
45 Correct 0 ms 204 KB Output is correct
46 Correct 1 ms 204 KB Output is correct
47 Correct 8 ms 372 KB Output is correct
48 Correct 0 ms 204 KB Output is correct
49 Correct 2 ms 204 KB Output is correct
50 Correct 1 ms 204 KB Output is correct
51 Correct 185 ms 2584 KB Output is correct
52 Correct 103 ms 1812 KB Output is correct
53 Correct 107 ms 1832 KB Output is correct
54 Correct 56 ms 972 KB Output is correct
55 Correct 167 ms 2336 KB Output is correct
56 Correct 43 ms 688 KB Output is correct
57 Correct 320 ms 4968 KB Output is correct
58 Correct 327 ms 4868 KB Output is correct
59 Correct 316 ms 4848 KB Output is correct
60 Correct 354 ms 4916 KB Output is correct
61 Correct 371 ms 5028 KB Output is correct
62 Correct 200 ms 5060 KB Output is correct
63 Correct 392 ms 4852 KB Output is correct
64 Correct 201 ms 4968 KB Output is correct
65 Correct 0 ms 204 KB Output is correct
66 Correct 181 ms 5036 KB Output is correct
67 Correct 332 ms 5008 KB Output is correct
68 Correct 320 ms 4868 KB Output is correct
69 Correct 41 ms 728 KB Output is correct
70 Correct 11 ms 420 KB Output is correct
71 Correct 0 ms 204 KB Output is correct
72 Correct 58 ms 960 KB Output is correct
73 Correct 14 ms 408 KB Output is correct
74 Correct 1 ms 204 KB Output is correct
75 Correct 399 ms 4972 KB Output is correct
76 Correct 365 ms 5000 KB Output is correct
77 Correct 360 ms 4932 KB Output is correct
78 Correct 421 ms 4968 KB Output is correct
79 Correct 385 ms 5028 KB Output is correct
80 Correct 397 ms 4968 KB Output is correct
81 Correct 345 ms 4852 KB Output is correct
82 Correct 324 ms 4932 KB Output is correct