Submission #786910

# Submission time Handle Problem Language Result Execution time Memory
786910 2023-07-18T14:35:21 Z WLZ Self Study (JOI22_ho_t2) C++17
100 / 100
372 ms 13840 KB
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) a[i] = max(a[i], b[i]);
 
  auto check = [&](__int128_t k) {
    vector<__int128_t> left(n, k);
    __int128_t weeks_left = (__int128_t) n * m;
    for (int i = 0; i < n; i++) {
      __int128_t div = min((__int128_t) m, (k + a[i] - 1) / a[i]);
      left[i] = max((__int128_t) 0, left[i] - a[i] * div);
      weeks_left -= div;
    }
    for (int i = 0; i < n; i++) weeks_left -= (left[i] + b[i] - 1) / b[i];
    return weeks_left >= 0;
  };
 
  __int128_t lo = 0, hi = (__int128_t) 2e18;
  while (lo < hi) {
    __int128_t mid = (lo + hi + 1) / 2;
    if (check(mid)) lo = mid;
    else hi = mid - 1;
  }
  cout << (long long) lo << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 274 ms 7356 KB Output is correct
12 Correct 273 ms 7364 KB Output is correct
13 Correct 259 ms 7360 KB Output is correct
14 Correct 309 ms 7332 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 354 ms 7308 KB Output is correct
17 Correct 276 ms 7568 KB Output is correct
18 Correct 280 ms 7440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 354 ms 7308 KB Output is correct
3 Correct 276 ms 7568 KB Output is correct
4 Correct 280 ms 7440 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 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 137 ms 3968 KB Output is correct
14 Correct 91 ms 2776 KB Output is correct
15 Correct 68 ms 2200 KB Output is correct
16 Correct 63 ms 1868 KB Output is correct
17 Correct 1 ms 252 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 320 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 6 ms 448 KB Output is correct
23 Correct 5 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 274 ms 7356 KB Output is correct
12 Correct 273 ms 7364 KB Output is correct
13 Correct 259 ms 7360 KB Output is correct
14 Correct 309 ms 7332 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 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 137 ms 3968 KB Output is correct
24 Correct 91 ms 2776 KB Output is correct
25 Correct 68 ms 2200 KB Output is correct
26 Correct 63 ms 1868 KB Output is correct
27 Correct 1 ms 252 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 6 ms 448 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 354 ms 7308 KB Output is correct
36 Correct 276 ms 7568 KB Output is correct
37 Correct 280 ms 7440 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 320 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 0 ms 212 KB Output is correct
45 Correct 5 ms 460 KB Output is correct
46 Correct 9 ms 712 KB Output is correct
47 Correct 1 ms 328 KB Output is correct
48 Correct 48 ms 2524 KB Output is correct
49 Correct 1 ms 320 KB Output is correct
50 Correct 1 ms 316 KB Output is correct
51 Correct 5 ms 468 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 152 ms 6612 KB Output is correct
56 Correct 89 ms 3924 KB Output is correct
57 Correct 103 ms 3936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 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 137 ms 3968 KB Output is correct
10 Correct 91 ms 2776 KB Output is correct
11 Correct 68 ms 2200 KB Output is correct
12 Correct 63 ms 1868 KB Output is correct
13 Correct 1 ms 252 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 0 ms 320 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 6 ms 448 KB Output is correct
19 Correct 5 ms 460 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 354 ms 7308 KB Output is correct
22 Correct 276 ms 7568 KB Output is correct
23 Correct 280 ms 7440 KB Output is correct
24 Correct 48 ms 2308 KB Output is correct
25 Correct 147 ms 6080 KB Output is correct
26 Correct 30 ms 1640 KB Output is correct
27 Correct 271 ms 13172 KB Output is correct
28 Correct 286 ms 13160 KB Output is correct
29 Correct 276 ms 13172 KB Output is correct
30 Correct 305 ms 13172 KB Output is correct
31 Correct 304 ms 13196 KB Output is correct
32 Correct 367 ms 8536 KB Output is correct
33 Correct 331 ms 13840 KB Output is correct
34 Correct 372 ms 8532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 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 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 4 ms 340 KB Output is correct
11 Correct 274 ms 7356 KB Output is correct
12 Correct 273 ms 7364 KB Output is correct
13 Correct 259 ms 7360 KB Output is correct
14 Correct 309 ms 7332 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 324 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 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 137 ms 3968 KB Output is correct
24 Correct 91 ms 2776 KB Output is correct
25 Correct 68 ms 2200 KB Output is correct
26 Correct 63 ms 1868 KB Output is correct
27 Correct 1 ms 252 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 0 ms 320 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 6 ms 448 KB Output is correct
33 Correct 5 ms 460 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 1 ms 212 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 0 ms 212 KB Output is correct
41 Correct 5 ms 460 KB Output is correct
42 Correct 9 ms 712 KB Output is correct
43 Correct 1 ms 328 KB Output is correct
44 Correct 48 ms 2524 KB Output is correct
45 Correct 1 ms 320 KB Output is correct
46 Correct 1 ms 316 KB Output is correct
47 Correct 5 ms 468 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 0 ms 212 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 152 ms 6612 KB Output is correct
52 Correct 89 ms 3924 KB Output is correct
53 Correct 103 ms 3936 KB Output is correct
54 Correct 48 ms 2308 KB Output is correct
55 Correct 147 ms 6080 KB Output is correct
56 Correct 30 ms 1640 KB Output is correct
57 Correct 271 ms 13172 KB Output is correct
58 Correct 286 ms 13160 KB Output is correct
59 Correct 276 ms 13172 KB Output is correct
60 Correct 305 ms 13172 KB Output is correct
61 Correct 304 ms 13196 KB Output is correct
62 Correct 367 ms 8536 KB Output is correct
63 Correct 331 ms 13840 KB Output is correct
64 Correct 372 ms 8532 KB Output is correct
65 Correct 0 ms 212 KB Output is correct
66 Correct 354 ms 7308 KB Output is correct
67 Correct 276 ms 7568 KB Output is correct
68 Correct 280 ms 7440 KB Output is correct
69 Correct 34 ms 1720 KB Output is correct
70 Correct 9 ms 540 KB Output is correct
71 Correct 0 ms 212 KB Output is correct
72 Correct 46 ms 2168 KB Output is correct
73 Correct 11 ms 716 KB Output is correct
74 Correct 1 ms 340 KB Output is correct
75 Correct 277 ms 13168 KB Output is correct
76 Correct 275 ms 13160 KB Output is correct
77 Correct 284 ms 13172 KB Output is correct
78 Correct 301 ms 13172 KB Output is correct
79 Correct 321 ms 13168 KB Output is correct
80 Correct 317 ms 13168 KB Output is correct
81 Correct 318 ms 11268 KB Output is correct
82 Correct 364 ms 11184 KB Output is correct