結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー BantakoBantako
提出日時 2018-05-30 19:10:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 744 bytes
コンパイル時間 1,608 ms
コンパイル使用メモリ 167,000 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-26 00:29:46
合計ジャッジ時間 3,900 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 20 ms
6,944 KB
testcase_03 AC 38 ms
6,944 KB
testcase_04 AC 51 ms
6,940 KB
testcase_05 AC 50 ms
6,940 KB
testcase_06 AC 48 ms
6,940 KB
testcase_07 AC 53 ms
6,940 KB
testcase_08 AC 53 ms
6,940 KB
testcase_09 AC 49 ms
6,940 KB
testcase_10 AC 47 ms
6,944 KB
testcase_11 AC 49 ms
6,944 KB
testcase_12 AC 43 ms
6,944 KB
testcase_13 AC 49 ms
6,940 KB
testcase_14 AC 51 ms
6,940 KB
testcase_15 AC 44 ms
6,940 KB
testcase_16 AC 45 ms
6,940 KB
testcase_17 AC 43 ms
6,944 KB
testcase_18 AC 43 ms
6,940 KB
testcase_19 AC 44 ms
6,940 KB
testcase_20 AC 42 ms
6,940 KB
testcase_21 AC 45 ms
6,944 KB
testcase_22 AC 38 ms
6,940 KB
testcase_23 AC 40 ms
6,940 KB
testcase_24 AC 1 ms
6,944 KB
testcase_25 AC 3 ms
6,944 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 10 ms
6,944 KB
testcase_29 AC 6 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
double INF = 1e9;
double EPS = 1e-9;
int MOD = 1e9+7;
vector<ll> V;
ll countup(double len){
    ll cnt = 0;
    for(auto i:V){
        cnt += (ll)floor(i / len);
    }
    return cnt;
}
main(){
    ll N,K;
    cin >> N;
    V.resize(N);
    rep(i,N)scanf("%lld",&V[i]);
    cin >> K;
    double ok = EPS,ng = INF;
    //while(fabs(ok - ng) > EPS){
    while(fabs(ok - ng) > EPS && (fabs(ok - ng) / ok) > EPS){
        //for(int i = 0;i < 100;i++){
        double mid = (ok + ng) / 2;
        if(countup(mid) >= K)ok = mid;
        else                 ng = mid;
        //cout << ok << endl;
    }
    printf("%.9lf\n",ok);
}
0