結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー ttakanottakano
提出日時 2017-12-05 10:48:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 949 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 146,972 KB
実行使用メモリ 9,404 KB
最終ジャッジ日時 2023-08-19 03:19:27
合計ジャッジ時間 11,981 ms
ジャッジサーバーID
(参考情報)
judge10 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 65 ms
4,380 KB
testcase_03 AC 124 ms
4,744 KB
testcase_04 AC 148 ms
5,012 KB
testcase_05 AC 148 ms
5,176 KB
testcase_06 AC 148 ms
5,120 KB
testcase_07 AC 169 ms
5,196 KB
testcase_08 AC 171 ms
5,268 KB
testcase_09 AC 170 ms
5,176 KB
testcase_10 AC 133 ms
4,852 KB
testcase_11 AC 141 ms
5,068 KB
testcase_12 AC 128 ms
4,800 KB
testcase_13 AC 155 ms
4,884 KB
testcase_14 AC 162 ms
4,936 KB
testcase_15 AC 144 ms
4,896 KB
testcase_16 TLE -
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.000000001){
    double mid=(left+right)/2;
    ll 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