제출 #692246

#제출 시각아이디문제언어결과실행 시간메모리
692246bdlSelf Study (JOI22_ho_t2)C++17
0 / 100
463 ms8436 KiB
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <array>
#include <iostream>
using namespace std;

#define ar array

const int N = 3e5;

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 = 1e18;
  while (low < hi) {
    long long t = (low + hi) / 2 + 1, c = 0;
    for (int i = 0; i < n; i++) {
      long long x = (t - 1) / a[i] + 1;
      if (x <= m)
        c += m - x;
      else
        c -= (t - 1LL * m * a[i] - 1) / b[i] + 1;
    }
    if (c >= 0)
      low = t;
    else
      hi = t - 1;
  }
  printf("%lld\n", low);
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d%d", &n, &m);
      |   ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |     scanf("%d", &a[i]);
      |     ~~~~~^~~~~~~~~~~~~
Main.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     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...