結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ttakanottakano
提出日時 2017-12-05 10:46:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 952 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 147,276 KB
実行使用メモリ 9,348 KB
最終ジャッジ日時 2023-08-19 03:18:34
合計ジャッジ時間 11,425 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
#define printall(n,array) for(int i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 1000000007; //10^9+7

int n;
ll l[202020];
ll k;

int main(){
  cin>>n;
  ll big=0;
  REP(i,n){
    cin>>l[i];
    big=max(big,l[i]);
  }
  cin>>k;
  sort(l,l+n);
  double right=big;
  double left=0;
  double max_=0;
  while(right-left>0.00000000001){
    double mid=(left+right)/2;
    int val=0;
    REP(i,n){
      val+=l[i]/mid;
    }
    //print(left<<" "<<right<<" "<<mid);///
    //print(val);///
    if(val<k){right=mid;}
    else if(val>=k){
      left=mid;
      if(val==k){
        max_=max(max_,mid);
        //print("max "<<max_);///
      }
    }
  }
  printf("%.10f",max_);
  print("");
}
0