Submission #940284

# Submission time Handle Problem Language Result Execution time Memory
940284 2024-03-07T07:30:20 Z TAhmed33 Self Study (JOI22_ho_t2) C++
0 / 100
305 ms 13772 KB
    #include <bits/stdc++.h>
    using namespace std;
#pragma GCC optimize ("trapv")
    typedef long long ll;
    const int MAXN = 3e5 + 25;
    ll n, m;
    pair <ll, ll> a[MAXN];
    void solve () {
    	cin >> n >> m;
    	for (int i = 1; i <= n; i++) cin >> a[i].first;
    	for (int i = 1; i <= n; i++) cin >> a[i].second;
    	ll l = 0, r = 1e18, ans = 0;
    	while (l <= r) {
    		ll mid = (l + r) / 2;
    		ll sum = 0;
    		for (int i = 1; i <= n; i++) {
    			ll x = (mid + max(a[i].first, a[i].second) - 1) / max(a[i].second, a[i].first);
    			if (x <= m) {
    				sum += x;
    			} else {
    				sum += ((mid - max(a[i].second, a[i].first) * m + a[i].second - 1) / a[i].second) + m;
    			}
    		}
    		if (sum <= n * m) {
    			l = mid + 1; ans = mid;
    		} else {
    			r = mid - 1;
    		}
    	}
    	cout << ans << '\n';
    }	
    int main () {
    	ios::sync_with_stdio(0); cin.tie(0);
    	int t = 1; //cin >> t;
    	while (t--) solve();
    }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 480 KB Output is correct
11 Correct 294 ms 10744 KB Output is correct
12 Correct 283 ms 10928 KB Output is correct
13 Correct 305 ms 8944 KB Output is correct
14 Runtime error 47 ms 13772 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 152 ms 7536 KB Output is correct
10 Correct 104 ms 4608 KB Output is correct
11 Correct 74 ms 4132 KB Output is correct
12 Correct 63 ms 3840 KB Output is correct
13 Correct 1 ms 480 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 604 KB Execution killed with signal 6
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 480 KB Output is correct
11 Correct 294 ms 10744 KB Output is correct
12 Correct 283 ms 10928 KB Output is correct
13 Correct 305 ms 8944 KB Output is correct
14 Runtime error 47 ms 13772 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 464 KB Output is correct
7 Correct 0 ms 464 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 152 ms 7536 KB Output is correct
10 Correct 104 ms 4608 KB Output is correct
11 Correct 74 ms 4132 KB Output is correct
12 Correct 63 ms 3840 KB Output is correct
13 Correct 1 ms 480 KB Output is correct
14 Correct 0 ms 464 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Runtime error 1 ms 604 KB Execution killed with signal 6
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 464 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 5 ms 480 KB Output is correct
11 Correct 294 ms 10744 KB Output is correct
12 Correct 283 ms 10928 KB Output is correct
13 Correct 305 ms 8944 KB Output is correct
14 Runtime error 47 ms 13772 KB Execution killed with signal 6
15 Halted 0 ms 0 KB -