Submission #729252

# Submission time Handle Problem Language Result Execution time Memory
729252 2023-04-23T17:30:19 Z tch1cherin Self Study (JOI22_ho_t2) C++17
64 / 100
250 ms 9124 KB
#include <bits/stdc++.h>
using namespace std;

const long long MAX_ANSWER = 2e18 + 5;

void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n), b(n);
  for (int &v : a) {
    cin >> v;
  }
  for (int &v : b) {
    cin >> v;
  }
  if (m == 1) {
    int ans = INT_MAX;
    for (int i = 0; i < n; i++) {
      ans = min(ans, max(a[i], b[i]));
    }
    cout << ans << "\n";
  } else {
    long long l = -1, r = MAX_ANSWER;
    while (r > l + 1) {
      long long mid = (l + r) / 2;
      long long req = 0;
      for (int i = 0; i < n; i++) {
        req += (mid + b[i] - 1) / b[i];
        req = min(req, MAX_ANSWER); 
      }
      if (req > 1ll * n * m) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << l << "\n";
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}
# 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 1 ms 340 KB Output is correct
11 Correct 59 ms 2644 KB Output is correct
12 Correct 59 ms 2644 KB Output is correct
13 Correct 51 ms 2660 KB Output is correct
14 Correct 50 ms 2660 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 29 ms 2644 KB Output is correct
17 Correct 78 ms 2668 KB Output is correct
18 Correct 54 ms 2664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 29 ms 2644 KB Output is correct
3 Correct 78 ms 2668 KB Output is correct
4 Correct 54 ms 2664 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 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 84 ms 4304 KB Output is correct
14 Correct 57 ms 3012 KB Output is correct
15 Correct 43 ms 2372 KB Output is correct
16 Correct 34 ms 1932 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 4 ms 372 KB Output is correct
23 Correct 4 ms 340 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 1 ms 340 KB Output is correct
11 Correct 59 ms 2644 KB Output is correct
12 Correct 59 ms 2644 KB Output is correct
13 Correct 51 ms 2660 KB Output is correct
14 Correct 50 ms 2660 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 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 84 ms 4304 KB Output is correct
24 Correct 57 ms 3012 KB Output is correct
25 Correct 43 ms 2372 KB Output is correct
26 Correct 34 ms 1932 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 4 ms 372 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 29 ms 2644 KB Output is correct
36 Correct 78 ms 2668 KB Output is correct
37 Correct 54 ms 2664 KB Output is correct
38 Incorrect 1 ms 316 KB Output isn't correct
39 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 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 1 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 84 ms 4304 KB Output is correct
10 Correct 57 ms 3012 KB Output is correct
11 Correct 43 ms 2372 KB Output is correct
12 Correct 34 ms 1932 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 340 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 Correct 4 ms 372 KB Output is correct
19 Correct 4 ms 340 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 29 ms 2644 KB Output is correct
22 Correct 78 ms 2668 KB Output is correct
23 Correct 54 ms 2664 KB Output is correct
24 Correct 36 ms 1592 KB Output is correct
25 Correct 99 ms 3932 KB Output is correct
26 Correct 25 ms 1068 KB Output is correct
27 Correct 173 ms 8420 KB Output is correct
28 Correct 172 ms 8464 KB Output is correct
29 Correct 172 ms 8412 KB Output is correct
30 Correct 182 ms 8476 KB Output is correct
31 Correct 236 ms 8468 KB Output is correct
32 Correct 228 ms 3788 KB Output is correct
33 Correct 250 ms 9124 KB Output is correct
34 Correct 231 ms 3836 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 1 ms 340 KB Output is correct
11 Correct 59 ms 2644 KB Output is correct
12 Correct 59 ms 2644 KB Output is correct
13 Correct 51 ms 2660 KB Output is correct
14 Correct 50 ms 2660 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 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 84 ms 4304 KB Output is correct
24 Correct 57 ms 3012 KB Output is correct
25 Correct 43 ms 2372 KB Output is correct
26 Correct 34 ms 1932 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 4 ms 372 KB Output is correct
33 Correct 4 ms 340 KB Output is correct
34 Incorrect 1 ms 316 KB Output isn't correct
35 Halted 0 ms 0 KB -