Submission #969202

# Submission time Handle Problem Language Result Execution time Memory
969202 2024-04-24T16:27:45 Z yellowtoad Self Study (JOI22_ho_t2) C++17
0 / 100
281 ms 5300 KB
#include <iostream>
#include <algorithm>
#define f first
#define s second
using namespace std;

long long n, m, a[300010], b[300010], l = 0, r = 4e14, mid, cnt, req;

bool check() {
	cnt = req = 0;
	for (int i = 1; i <= n; i++) {
		if (b[i] > a[i]) {
			cnt += m;
			req += (mid+b[i]-1)/b[i];
		} else {
			if (a[i]*m >= mid) cnt += (a[i]*m-mid)/a[i];
			else req += (mid-a[i]*m+b[i]-1)/b[i];
		}
	}
	if (cnt < req) return 0;
	else return 1;
}

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];
	while (l <= r) {
		mid = (l+r)/2;
		if (!check()) r = mid-1;
		else l = mid+1;
	}
	cout << r << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 240 ms 5300 KB Output is correct
12 Correct 239 ms 5044 KB Output is correct
13 Correct 191 ms 5108 KB Output is correct
14 Incorrect 281 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 116 ms 4528 KB Output is correct
10 Correct 78 ms 4688 KB Output is correct
11 Correct 59 ms 4688 KB Output is correct
12 Correct 48 ms 4700 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 3 ms 2396 KB Output is correct
19 Correct 4 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Incorrect 224 ms 5104 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 240 ms 5300 KB Output is correct
12 Correct 239 ms 5044 KB Output is correct
13 Correct 191 ms 5108 KB Output is correct
14 Incorrect 281 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 0 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 116 ms 4528 KB Output is correct
10 Correct 78 ms 4688 KB Output is correct
11 Correct 59 ms 4688 KB Output is correct
12 Correct 48 ms 4700 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 3 ms 2396 KB Output is correct
19 Correct 4 ms 2396 KB Output is correct
20 Correct 0 ms 2396 KB Output is correct
21 Incorrect 224 ms 5104 KB Output isn't correct
22 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 4 ms 2396 KB Output is correct
11 Correct 240 ms 5300 KB Output is correct
12 Correct 239 ms 5044 KB Output is correct
13 Correct 191 ms 5108 KB Output is correct
14 Incorrect 281 ms 4944 KB Output isn't correct
15 Halted 0 ms 0 KB -