Submission #860971

# Submission time Handle Problem Language Result Execution time Memory
860971 2023-10-15T01:53:12 Z NeroZein Self Study (JOI22_ho_t2) C++17
0 / 100
425 ms 2792 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) {
    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];          
        }
      }
    }
    return days <= (long long) n * m; 
  }; 
  long long l = 0, r = 1e18;
  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 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 0 ms 348 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 179 ms 2652 KB Output is correct
12 Correct 179 ms 2792 KB Output is correct
13 Correct 134 ms 2792 KB Output is correct
14 Incorrect 425 ms 2792 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 360 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 72 ms 1624 KB Output is correct
10 Correct 47 ms 1112 KB Output is correct
11 Correct 36 ms 860 KB Output is correct
12 Correct 29 ms 860 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 0 ms 344 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 348 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 0 ms 348 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 179 ms 2652 KB Output is correct
12 Correct 179 ms 2792 KB Output is correct
13 Correct 134 ms 2792 KB Output is correct
14 Incorrect 425 ms 2792 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 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 360 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 72 ms 1624 KB Output is correct
10 Correct 47 ms 1112 KB Output is correct
11 Correct 36 ms 860 KB Output is correct
12 Correct 29 ms 860 KB Output is correct
13 Correct 1 ms 600 KB Output is correct
14 Correct 0 ms 344 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 348 KB Output is correct
18 Incorrect 4 ms 348 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 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 0 ms 348 KB Output is correct
10 Correct 3 ms 344 KB Output is correct
11 Correct 179 ms 2652 KB Output is correct
12 Correct 179 ms 2792 KB Output is correct
13 Correct 134 ms 2792 KB Output is correct
14 Incorrect 425 ms 2792 KB Output isn't correct
15 Halted 0 ms 0 KB -