Submission #786866

# Submission time Handle Problem Language Result Execution time Memory
786866 2023-07-18T14:02:57 Z WLZ Self Study (JOI22_ho_t2) C++17
0 / 100
452 ms 5064 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];

  auto check = [&](long long k) {
    vector<long long> left(n, k);
    long long weeks_left = (long long) n * m;
    for (int i = 0; i < n; i++) {
      if (a[i] <= b[i]) continue;
      long long div = min((long long) m, (k + a[i] - 1) / a[i]);
      left[i] = max(0ll, 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;
  };

  long long lo = 0, hi = (long long) 2e18;
  while (lo < hi) {
    long long mid = (lo + hi + 1) / 2;
    if (check(mid)) lo = mid;
    else hi = mid - 1;
  }
  cout << lo << '\n';
  return 0;
}
# 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 224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 257 ms 4976 KB Output is correct
12 Correct 256 ms 5008 KB Output is correct
13 Correct 160 ms 5012 KB Output is correct
14 Incorrect 452 ms 5064 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 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 85 ms 2668 KB Output is correct
10 Correct 57 ms 1876 KB Output is correct
11 Correct 43 ms 1492 KB Output is correct
12 Correct 37 ms 1268 KB Output is correct
13 Correct 1 ms 320 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 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 257 ms 4976 KB Output is correct
12 Correct 256 ms 5008 KB Output is correct
13 Correct 160 ms 5012 KB Output is correct
14 Incorrect 452 ms 5064 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 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 85 ms 2668 KB Output is correct
10 Correct 57 ms 1876 KB Output is correct
11 Correct 43 ms 1492 KB Output is correct
12 Correct 37 ms 1268 KB Output is correct
13 Correct 1 ms 320 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 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 224 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 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 257 ms 4976 KB Output is correct
12 Correct 256 ms 5008 KB Output is correct
13 Correct 160 ms 5012 KB Output is correct
14 Incorrect 452 ms 5064 KB Output isn't correct
15 Halted 0 ms 0 KB -