Submission #860973

# Submission time Handle Problem Language Result Execution time Memory
860973 2023-10-15T01:56:48 Z NeroZein Self Study (JOI22_ho_t2) C++17
100 / 100
209 ms 9068 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  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]; 
  }
  auto ch = [&](long long mid) -> bool {
    long long days = 0; 
    for (int i = 0; i < n; ++i) {
      if (b[i] >= a[i]) {
        days += (mid + b[i] - 1) / b[i]; 
      } else {
        int t = min((long long) m, (mid + a[i] - 1) / a[i]);
        days += t;
        if (mid - (long long) a[i] * t > 0) {
          days += (mid - (long long) a[i] * t + b[i] - 1) / b[i];          
        }
      }
      if (days > (long long) n * m) {
        return false;
      }
    }
    return true; 
  }; 
  long long l = 0, r = 2e18;
  while (l < r) {
    long long mid = (l + r + 1) / 2;
    if (ch(mid)) l = mid;
    else r = mid - 1;
  }
  cout << l << '\n'; 
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 88 ms 2792 KB Output is correct
12 Correct 96 ms 2648 KB Output is correct
13 Correct 73 ms 2804 KB Output is correct
14 Correct 56 ms 2652 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 27 ms 3956 KB Output is correct
17 Correct 79 ms 9068 KB Output is correct
18 Correct 81 ms 8412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 27 ms 3956 KB Output is correct
3 Correct 79 ms 9068 KB Output is correct
4 Correct 81 ms 8412 KB Output is correct
5 Correct 0 ms 344 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 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 40 ms 1628 KB Output is correct
14 Correct 28 ms 1372 KB Output is correct
15 Correct 23 ms 860 KB Output is correct
16 Correct 17 ms 860 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 464 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 88 ms 2792 KB Output is correct
12 Correct 96 ms 2648 KB Output is correct
13 Correct 73 ms 2804 KB Output is correct
14 Correct 56 ms 2652 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 40 ms 1628 KB Output is correct
24 Correct 28 ms 1372 KB Output is correct
25 Correct 23 ms 860 KB Output is correct
26 Correct 17 ms 860 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 27 ms 3956 KB Output is correct
36 Correct 79 ms 9068 KB Output is correct
37 Correct 81 ms 8412 KB Output is correct
38 Correct 1 ms 456 KB Output is correct
39 Correct 0 ms 344 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 344 KB Output is correct
46 Correct 3 ms 604 KB Output is correct
47 Correct 1 ms 484 KB Output is correct
48 Correct 17 ms 1628 KB Output is correct
49 Correct 1 ms 344 KB Output is correct
50 Correct 0 ms 420 KB Output is correct
51 Correct 2 ms 348 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 1 ms 348 KB Output is correct
55 Correct 48 ms 4300 KB Output is correct
56 Correct 26 ms 2396 KB Output is correct
57 Correct 22 ms 2396 KB Output is correct
# 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 40 ms 1628 KB Output is correct
10 Correct 28 ms 1372 KB Output is correct
11 Correct 23 ms 860 KB Output is correct
12 Correct 17 ms 860 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 348 KB Output is correct
17 Correct 0 ms 344 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 464 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 27 ms 3956 KB Output is correct
22 Correct 79 ms 9068 KB Output is correct
23 Correct 81 ms 8412 KB Output is correct
24 Correct 26 ms 1696 KB Output is correct
25 Correct 61 ms 4096 KB Output is correct
26 Correct 11 ms 1112 KB Output is correct
27 Correct 80 ms 8588 KB Output is correct
28 Correct 84 ms 8540 KB Output is correct
29 Correct 87 ms 8676 KB Output is correct
30 Correct 107 ms 8528 KB Output is correct
31 Correct 180 ms 8592 KB Output is correct
32 Correct 108 ms 3964 KB Output is correct
33 Correct 205 ms 9068 KB Output is correct
34 Correct 106 ms 3960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 2 ms 348 KB Output is correct
11 Correct 88 ms 2792 KB Output is correct
12 Correct 96 ms 2648 KB Output is correct
13 Correct 73 ms 2804 KB Output is correct
14 Correct 56 ms 2652 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 40 ms 1628 KB Output is correct
24 Correct 28 ms 1372 KB Output is correct
25 Correct 23 ms 860 KB Output is correct
26 Correct 17 ms 860 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 464 KB Output is correct
34 Correct 1 ms 456 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 3 ms 604 KB Output is correct
43 Correct 1 ms 484 KB Output is correct
44 Correct 17 ms 1628 KB Output is correct
45 Correct 1 ms 344 KB Output is correct
46 Correct 0 ms 420 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 0 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 48 ms 4300 KB Output is correct
52 Correct 26 ms 2396 KB Output is correct
53 Correct 22 ms 2396 KB Output is correct
54 Correct 26 ms 1696 KB Output is correct
55 Correct 61 ms 4096 KB Output is correct
56 Correct 11 ms 1112 KB Output is correct
57 Correct 80 ms 8588 KB Output is correct
58 Correct 84 ms 8540 KB Output is correct
59 Correct 87 ms 8676 KB Output is correct
60 Correct 107 ms 8528 KB Output is correct
61 Correct 180 ms 8592 KB Output is correct
62 Correct 108 ms 3964 KB Output is correct
63 Correct 205 ms 9068 KB Output is correct
64 Correct 106 ms 3960 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 27 ms 3956 KB Output is correct
67 Correct 79 ms 9068 KB Output is correct
68 Correct 81 ms 8412 KB Output is correct
69 Correct 21 ms 1372 KB Output is correct
70 Correct 5 ms 604 KB Output is correct
71 Correct 0 ms 596 KB Output is correct
72 Correct 29 ms 1624 KB Output is correct
73 Correct 6 ms 604 KB Output is correct
74 Correct 1 ms 464 KB Output is correct
75 Correct 101 ms 8552 KB Output is correct
76 Correct 111 ms 8788 KB Output is correct
77 Correct 125 ms 8532 KB Output is correct
78 Correct 149 ms 8528 KB Output is correct
79 Correct 201 ms 8584 KB Output is correct
80 Correct 209 ms 8532 KB Output is correct
81 Correct 197 ms 6604 KB Output is correct
82 Correct 173 ms 6492 KB Output is correct