結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー vjudge1
提出日時 2024-11-05 17:52:17
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,343 ms / 5,000 ms
コード長 660 bytes
コンパイル時間 3,355 ms
コンパイル使用メモリ 273,344 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-03-03 12:14:59
合計ジャッジ時間 34,788 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define endl "\n"
typedef long long ll;
#define int long long
int n, k;
int a[200005];
bool check(double x) {
  int ans = 0;
  for (int i = 1; i <= n; i++) ans += (int)a[i] / x;
  return ans >= k;
}
void solved() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cin >> k;
  double l = 0, r = 1e9;
  for (int i = 1; i <= 1000; i++) {
    double mid = (l + r + 1) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%.15lf\n", l);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  /*int t = 1;
  cin >> t;
  while (t--)*/
  solved();

  return 0;
}
0