結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー 0w10w1
提出日時 2016-11-27 22:24:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 5,000 ms
コード長 621 bytes
コンパイル時間 1,670 ms
コンパイル使用メモリ 166,328 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 23:45:26
合計ジャッジ時間 7,481 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 215 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 82 ms
6,944 KB
testcase_03 AC 154 ms
6,940 KB
testcase_04 AC 188 ms
6,944 KB
testcase_05 AC 189 ms
6,944 KB
testcase_06 AC 186 ms
6,940 KB
testcase_07 AC 213 ms
6,940 KB
testcase_08 AC 211 ms
6,944 KB
testcase_09 AC 212 ms
6,940 KB
testcase_10 AC 168 ms
6,944 KB
testcase_11 AC 180 ms
6,944 KB
testcase_12 AC 162 ms
6,944 KB
testcase_13 AC 189 ms
6,944 KB
testcase_14 AC 203 ms
6,944 KB
testcase_15 AC 183 ms
6,940 KB
testcase_16 AC 190 ms
6,944 KB
testcase_17 AC 187 ms
6,944 KB
testcase_18 AC 189 ms
6,944 KB
testcase_19 AC 211 ms
6,940 KB
testcase_20 AC 211 ms
6,944 KB
testcase_21 AC 212 ms
6,940 KB
testcase_22 AC 167 ms
6,944 KB
testcase_23 AC 181 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 3 ms
6,948 KB
testcase_28 AC 35 ms
6,944 KB
testcase_29 AC 19 ms
6,940 KB
testcase_30 AC 6 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int ok( const vector< int > &stick, ll k, double len ){
  for( int i = 0; i < stick.size(); ++i )
    k -= floor( 1.0 * stick[ i ] / len );
  return k <= 0;
}

signed main(){
  int N; cin >> N;
  vector< int > L( N );
  for( int i = 0; i < N; ++i )
    cin >> L[ i ];
  ll K; cin >> K;
  double lb = 0.0, rb = *max_element( L.begin(), L.end() );
  for( int i = 0; i < 100; ++i ){
    double mid = ( lb + rb ) / 2;
    if( ok( L, K, mid ) )
      lb = mid;
    else
      rb = mid;
  }
  cout << fixed << setprecision( 10 ) << lb << endl;
  return 0;
}
0