Submission #860972

# Submission time Handle Problem Language Result Execution time Memory
860972 2023-10-15T01:55:44 Z NeroZein Self Study (JOI22_ho_t2) C++17
0 / 100
0 ms 600 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 = 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 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -