Submission #923322

# Submission time Handle Problem Language Result Execution time Memory
923322 2024-02-07T06:19:12 Z goodspeed0208 Self Study (JOI22_ho_t2) C++14
0 / 100
274 ms 10940 KB
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
using namespace std;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<int>a(n), b(n);
	for (auto &i : a) cin >> i;
	for (auto &i : b) cin >> i;
	
	int l = 0, r = (1e18) + 5, mid;
	while (l + 1 < r) {
		mid = (l + r) / 2;
		int need = 0;
		for (int i = 0 ; i < n ; i++) {
			if (a[i] > b[i]) {
				if (mid > a[i] * m) need += m + (mid - a[i] * m) / b[i] + ((mid - a[i] * m) % b[i] != 0 ? 1 : 0);
				else need += (mid / a[i]) + (mid % a[i] != 0 ? 1 : 0);
			} else {
				need += (mid / b[i]) + (mid % b[i] != 0 ? 1 : 0);
			}
		}
		if (need <= n * m) {
			l = mid;
			//cout << l << " " << need << "\n";
		} else {
			r = 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 155 ms 10760 KB Output is correct
12 Correct 149 ms 10940 KB Output is correct
13 Correct 132 ms 8848 KB Output is correct
14 Incorrect 274 ms 8788 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 73 ms 5580 KB Output is correct
10 Correct 49 ms 3952 KB Output is correct
11 Correct 36 ms 2908 KB Output is correct
12 Correct 32 ms 2392 KB Output is correct
13 Correct 1 ms 348 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 344 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 155 ms 10760 KB Output is correct
12 Correct 149 ms 10940 KB Output is correct
13 Correct 132 ms 8848 KB Output is correct
14 Incorrect 274 ms 8788 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 73 ms 5580 KB Output is correct
10 Correct 49 ms 3952 KB Output is correct
11 Correct 36 ms 2908 KB Output is correct
12 Correct 32 ms 2392 KB Output is correct
13 Correct 1 ms 348 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 344 KB Output is correct
17 Correct 0 ms 600 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 3 ms 580 KB Output is correct
11 Correct 155 ms 10760 KB Output is correct
12 Correct 149 ms 10940 KB Output is correct
13 Correct 132 ms 8848 KB Output is correct
14 Incorrect 274 ms 8788 KB Output isn't correct
15 Halted 0 ms 0 KB -