Submission #684784

# Submission time Handle Problem Language Result Execution time Memory
684784 2023-01-22T13:07:39 Z US3RN4M3 Self Study (JOI22_ho_t2) C++17
100 / 100
456 ms 11500 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, m;
vector<ll> A;
vector<ll> B;
bool test(ll goal) {
	ll avail = 0;
	for(ll i = 0; i < n; i++) {
		ll used = (goal - 1)/A[i] + 1;
		if(used <= m) {
			avail += m - used;
			continue;
		}
		ll left = goal - A[i]*m;
		ll req = (left - 1)/B[i] + 1;
		avail -= req;
		if(avail < -n*m) return false;
	}
	return (avail >= 0);
}
main() {
	cin >> n >> m;
	A.resize(n);
	B.resize(n);
	for(ll & i : A) cin >> i;
	for(ll & i : B) cin >> i;
	for(int i = 0; i < n; i++) A[i] = max(A[i], B[i]);
	ll ans = 0;
	for(ll delta = (1ll<<60); delta >= 1; delta >>= 1) {
		if(test(ans + delta)) ans += delta;
	}
	//ll ans2 = 1e18;
	//for(ll i = 0; i < n; i++) ans2 = min(ans2, max(A[i], B[i]));
	//if(m == 1 && ans2 != ans) assert(ans2 > ans);
	cout << ans << endl;
}

Compilation message

Main.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main() {
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 247 ms 4948 KB Output is correct
12 Correct 253 ms 4988 KB Output is correct
13 Correct 221 ms 4980 KB Output is correct
14 Correct 194 ms 4984 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 78 ms 4980 KB Output is correct
17 Correct 301 ms 4992 KB Output is correct
18 Correct 253 ms 4980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 78 ms 4980 KB Output is correct
3 Correct 301 ms 4992 KB Output is correct
4 Correct 253 ms 4980 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 130 ms 2644 KB Output is correct
14 Correct 87 ms 1876 KB Output is correct
15 Correct 61 ms 1364 KB Output is correct
16 Correct 52 ms 1240 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 6 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 247 ms 4948 KB Output is correct
12 Correct 253 ms 4988 KB Output is correct
13 Correct 221 ms 4980 KB Output is correct
14 Correct 194 ms 4984 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 130 ms 2644 KB Output is correct
24 Correct 87 ms 1876 KB Output is correct
25 Correct 61 ms 1364 KB Output is correct
26 Correct 52 ms 1240 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 440 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 78 ms 4980 KB Output is correct
36 Correct 301 ms 4992 KB Output is correct
37 Correct 253 ms 4980 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 0 ms 296 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 0 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 5 ms 468 KB Output is correct
46 Correct 8 ms 596 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 47 ms 2092 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 5 ms 440 KB Output is correct
52 Correct 0 ms 300 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 296 KB Output is correct
55 Correct 135 ms 5492 KB Output is correct
56 Correct 77 ms 3020 KB Output is correct
57 Correct 59 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 130 ms 2644 KB Output is correct
10 Correct 87 ms 1876 KB Output is correct
11 Correct 61 ms 1364 KB Output is correct
12 Correct 52 ms 1240 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 2 ms 340 KB Output is correct
19 Correct 6 ms 440 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 78 ms 4980 KB Output is correct
22 Correct 301 ms 4992 KB Output is correct
23 Correct 253 ms 4980 KB Output is correct
24 Correct 68 ms 1912 KB Output is correct
25 Correct 150 ms 4936 KB Output is correct
26 Correct 31 ms 1364 KB Output is correct
27 Correct 246 ms 10728 KB Output is correct
28 Correct 260 ms 10956 KB Output is correct
29 Correct 266 ms 10748 KB Output is correct
30 Correct 288 ms 10700 KB Output is correct
31 Correct 372 ms 10784 KB Output is correct
32 Correct 196 ms 6160 KB Output is correct
33 Correct 456 ms 11500 KB Output is correct
34 Correct 205 ms 6120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Correct 247 ms 4948 KB Output is correct
12 Correct 253 ms 4988 KB Output is correct
13 Correct 221 ms 4980 KB Output is correct
14 Correct 194 ms 4984 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 130 ms 2644 KB Output is correct
24 Correct 87 ms 1876 KB Output is correct
25 Correct 61 ms 1364 KB Output is correct
26 Correct 52 ms 1240 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 2 ms 340 KB Output is correct
33 Correct 6 ms 440 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 0 ms 212 KB Output is correct
37 Correct 0 ms 296 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 0 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 5 ms 468 KB Output is correct
42 Correct 8 ms 596 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 47 ms 2092 KB Output is correct
45 Correct 0 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 5 ms 440 KB Output is correct
48 Correct 0 ms 300 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 296 KB Output is correct
51 Correct 135 ms 5492 KB Output is correct
52 Correct 77 ms 3020 KB Output is correct
53 Correct 59 ms 3020 KB Output is correct
54 Correct 68 ms 1912 KB Output is correct
55 Correct 150 ms 4936 KB Output is correct
56 Correct 31 ms 1364 KB Output is correct
57 Correct 246 ms 10728 KB Output is correct
58 Correct 260 ms 10956 KB Output is correct
59 Correct 266 ms 10748 KB Output is correct
60 Correct 288 ms 10700 KB Output is correct
61 Correct 372 ms 10784 KB Output is correct
62 Correct 196 ms 6160 KB Output is correct
63 Correct 456 ms 11500 KB Output is correct
64 Correct 205 ms 6120 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 78 ms 4980 KB Output is correct
67 Correct 301 ms 4992 KB Output is correct
68 Correct 253 ms 4980 KB Output is correct
69 Correct 40 ms 1432 KB Output is correct
70 Correct 11 ms 572 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 56 ms 1800 KB Output is correct
73 Correct 12 ms 648 KB Output is correct
74 Correct 2 ms 212 KB Output is correct
75 Correct 262 ms 10700 KB Output is correct
76 Correct 275 ms 10724 KB Output is correct
77 Correct 294 ms 10780 KB Output is correct
78 Correct 323 ms 10700 KB Output is correct
79 Correct 383 ms 10868 KB Output is correct
80 Correct 389 ms 10740 KB Output is correct
81 Correct 380 ms 8808 KB Output is correct
82 Correct 332 ms 8800 KB Output is correct