Submission #969196

# Submission time Handle Problem Language Result Execution time Memory
969196 2024-04-24T16:24:55 Z yellowtoad Self Study (JOI22_ho_t2) C++17
0 / 100
357 ms 5288 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 = 1e18, 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 1 ms 2392 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 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 277 ms 5104 KB Output is correct
12 Correct 264 ms 4948 KB Output is correct
13 Correct 221 ms 5108 KB Output is correct
14 Incorrect 357 ms 5288 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 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 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 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 130 ms 4692 KB Output is correct
10 Correct 88 ms 4688 KB Output is correct
11 Correct 66 ms 4696 KB Output is correct
12 Correct 54 ms 4700 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 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 Incorrect 5 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 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 277 ms 5104 KB Output is correct
12 Correct 264 ms 4948 KB Output is correct
13 Correct 221 ms 5108 KB Output is correct
14 Incorrect 357 ms 5288 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 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 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 2392 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 130 ms 4692 KB Output is correct
10 Correct 88 ms 4688 KB Output is correct
11 Correct 66 ms 4696 KB Output is correct
12 Correct 54 ms 4700 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 0 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 Incorrect 5 ms 2396 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 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 277 ms 5104 KB Output is correct
12 Correct 264 ms 4948 KB Output is correct
13 Correct 221 ms 5108 KB Output is correct
14 Incorrect 357 ms 5288 KB Output isn't correct
15 Halted 0 ms 0 KB -