Submission #786860

# Submission time Handle Problem Language Result Execution time Memory
786860 2023-07-18T13:59:08 Z WLZ Self Study (JOI22_ho_t2) C++17
0 / 100
445 ms 10824 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], a[i] = max(a[i], 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++) {
      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 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 4 ms 480 KB Output is correct
11 Correct 252 ms 10788 KB Output is correct
12 Correct 258 ms 10824 KB Output is correct
13 Correct 243 ms 8824 KB Output is correct
14 Incorrect 445 ms 8836 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 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 128 ms 5588 KB Output is correct
10 Correct 87 ms 3788 KB Output is correct
11 Correct 64 ms 2964 KB Output is correct
12 Correct 51 ms 2380 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 9 ms 332 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 4 ms 480 KB Output is correct
11 Correct 252 ms 10788 KB Output is correct
12 Correct 258 ms 10824 KB Output is correct
13 Correct 243 ms 8824 KB Output is correct
14 Incorrect 445 ms 8836 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 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 128 ms 5588 KB Output is correct
10 Correct 87 ms 3788 KB Output is correct
11 Correct 64 ms 2964 KB Output is correct
12 Correct 51 ms 2380 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Incorrect 9 ms 332 KB Output isn't correct
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 320 KB Output is correct
10 Correct 4 ms 480 KB Output is correct
11 Correct 252 ms 10788 KB Output is correct
12 Correct 258 ms 10824 KB Output is correct
13 Correct 243 ms 8824 KB Output is correct
14 Incorrect 445 ms 8836 KB Output isn't correct
15 Halted 0 ms 0 KB -