結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー Bantako
提出日時 2018-05-30 17:06:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 663 bytes
コンパイル時間 1,614 ms
コンパイル使用メモリ 164,540 KB
実行使用メモリ 8,608 KB
最終ジャッジ日時 2025-03-03 11:13:33
合計ジャッジ時間 4,803 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:16:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
   16 | main(){
      | ^~~~
main.cpp: In function ‘int main()’:
main.cpp:20:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |    rep(i,N)scanf("%lld",&V[i]);
      |            ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
double INF = 1e9;
double EPS = 1e-9;
int MOD = 1e9+7;
vector<ll> V;
ll countup(double len){
    ll cnt = 0;
    for(auto i:V){
        cnt += (ll)floor(i / len);
    }
    return cnt;
}
main(){
   ll N,K;
   cin >> N;
   V.resize(N);
   rep(i,N)scanf("%lld",&V[i]);
   cin >> K;
   double ok = EPS,ng = INF;
   //while(fabs(ok - ng) > EPS){
    for(int i = 0;i < 100;i++){
       double mid = (ok + ng) / 2;
       if(countup(mid) >= K)ok = mid;
       else                 ng = mid;
       //cout << ok << endl;
   }
   printf("%.9lf\n",ok);
}
0