結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー to10to10to10toto10to10to10to
提出日時 2019-04-09 16:45:21
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 657 bytes
コンパイル時間 1,442 ms
コンパイル使用メモリ 165,480 KB
実行使用メモリ 5,184 KB
最終ジャッジ日時 2023-09-17 04:18:41
合計ジャッジ時間 6,867 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 158 ms
5,024 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 150 ms
5,020 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 165 ms
5,012 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 130 ms
4,908 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 142 ms
4,788 KB
testcase_16 AC 137 ms
5,012 KB
testcase_17 AC 134 ms
5,080 KB
testcase_18 AC 132 ms
5,056 KB
testcase_19 AC 153 ms
5,020 KB
testcase_20 AC 153 ms
5,012 KB
testcase_21 AC 153 ms
5,120 KB
testcase_22 AC 119 ms
4,904 KB
testcase_23 AC 126 ms
5,020 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 2 ms
4,380 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-12 || ng-ok <= ok*1e-12)){
    double mid = (ok+ng)/2;
    if(C(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << fixed << setprecision(12) << ok << endl;
}
0