結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー vjudge1
提出日時 2024-11-06 22:59:49
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,048 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 170,064 KB
実行使用メモリ 22,072 KB
最終ジャッジ日時 2025-03-03 12:16:44
合計ジャッジ時間 15,030 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ULL = unsigned long long;
#define INF 0x3f3f3f3f
#define llINF 0x3f3f3f3f3f3f3f3f
#define int long long
const int N = 1e6 + 10;
double a[N];
int n;
int k;

bool cheak(double x)
{
    if (x < 0.0000000001) return true;
    int res = 0;
    
    for (int i = 1; i <= n; i++)
    {
        res += (a[i] / x);
        //cout << res << endl;
    }
    
    return res >= k;
}

void solve() {
    cout << fixed << setprecision(15);
    cin >> n;
    for (int i = 1; i <= n; i++)cin >> a[i];
    cin >> k;
    double l = 0.00000000001, r = 6e18;
    while (l + 0.00000000001< r)
    {       
        
        double mid = (l + r) / 2; 
        if (mid <= 0.0000000001)
        {
            cout << 0.0000000000001 << endl;
            return;
        }
        if (cheak(mid)) l = mid;
        else r = mid;
    }
    cout << l << endl;
}


signed main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int T = 1; //cin >> T;
    while (T--) {
        solve();

    }


}
0