Submission #894222

#TimeUsernameProblemLanguageResultExecution timeMemory
894222boxSelf Study (JOI22_ho_t2)C++17
100 / 100
354 ms9220 KiB
#include <array>
#include <iostream>
using namespace std;
 
const int N = 3e5;
const long long INF = 1e18;
 
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  static int a[N], b[N];
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) {
    scanf("%d", &b[i]);
    a[i] = max(a[i], b[i]);
  }
  long long low = 0, hi = INF;
  while (low < hi) {
    long long t = (low + hi) / 2 + 1, c = 0;
    for (int i = 0; i < n; i++) {
      long long x = (t + a[i] - 1) / a[i];
      if (x <= m)
        c += m - x;
      else
        c = max(-INF, c - (t - 1LL * m * a[i] + b[i] - 1) / b[i]);
    }
    if (c >= 0)
      low = t;
    else
      hi = t - 1;
  }
  printf("%lld\n", low);
  return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:12:36: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |   for (int i = 0; i < n; i++) scanf("%d", &a[i]);
      |                               ~~~~~^~~~~~~~~~~~~
Main.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     scanf("%d", &b[i]);
      |     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...