結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー to10to10to10toto10to10to10to
提出日時 2019-04-09 16:43:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 164,924 KB
実行使用メモリ 5,224 KB
最終ジャッジ日時 2023-09-17 04:15:22
合計ジャッジ時間 8,232 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
5,000 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 131 ms
5,064 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 140 ms
5,148 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 114 ms
4,928 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 125 ms
4,836 KB
testcase_16 AC 124 ms
5,072 KB
testcase_17 AC 118 ms
5,144 KB
testcase_18 AC 116 ms
5,064 KB
testcase_19 AC 124 ms
5,140 KB
testcase_20 AC 134 ms
5,144 KB
testcase_21 AC 138 ms
5,144 KB
testcase_22 AC 98 ms
4,852 KB
testcase_23 AC 99 ms
5,072 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,376 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i,n) for(int i=0; i<n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)

int N,K;
double L[200010];

bool C(double x){//長さxの紐をK本作れるか
  int ret = 0;
  rep(i,N){
    ret += floor(L[i]/x);
  }
  return ret >= K;
}
int main(){
  cin >> N;
  rep(i,N){
    cin >> L[i];
  }
  cin >> K;

  double ok = 0, ng = 1000000000;
  while(!(ng-ok <= 1e-9 || ng-ok <= ok*1e-9)){
    double mid = (ok+ng)/2;
    if(C(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << fixed << setprecision(10) << ok << endl;
}
0