結果

問題 No.67 よくある棒を切る問題 (1)
コンテスト
ユーザー clukki
提出日時 2026-10-20 19:48:28
言語 C++23(gnu拡張gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=gnu++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 82 ms / 5,000 ms
+ 248µs
コード長 1,005 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,162 ms
コンパイル使用メモリ 356,868 KB
実行使用メモリ 9,920 KB
最終ジャッジ日時 2026-10-20 19:48:47
合計ジャッジ時間 9,331 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
template <class T> using vec = vector<T>;
// #define vec vector
typedef long long ll;
typedef vec<int> vi;
typedef vec<ll> vl;
#define M 1000000007
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(x) cout << #x << " = " << x << '\n'
#define db(x) #x << " = " << x << " "

// #define TEST

void realmain() {
  ll n,k;
  cin >> n;
  vl a(n);
  ll mx=0;
  for (int i=0;i<n;++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  cin >> k;

  double l=0,r=mx;
  for (int p=0;p<70;++p){
    double m=(l+r)/2;
    ll sm=0;
    for (auto &i:a) sm+=i/m;
    if (sm>=k) l=m;
    else r=m;
  }
  cout << fixed << setprecision(15) << l;
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);

#define N "YUBIYUBI"
  if (fopen(N ".inp", "r")) {
    freopen(N ".inp", "r", stdin);
    freopen(N ".out", "w", stdout);
  }

  ll t = 1;
#ifdef TEST
  cin >> t;
#endif // TEST

  while (t--) {
    realmain();
  }

  return 0;
}
0