結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー kopricky
提出日時 2017-08-18 07:59:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 1,462 bytes
コンパイル時間 1,336 ms
コンパイル使用メモリ 159,664 KB
実行使用メモリ 12,932 KB
最終ジャッジ日時 2025-03-03 10:52:44
合計ジャッジ時間 9,312 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 16 TLE * 1 -- * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:58:25: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘long double’ [-Wformat=]
   58 |             printf("%.10f\n",mid);
      |                     ~~~~^    ~~~
      |                         |    |
      |                         |    long double
      |                         double
      |                     %.10Lf

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-12
#define double long double
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> vec;
ll K;

bool possible(double cri)
{
    ll s = 0;
    rep(i,vec.size()){
        s += (ll)(vec[i]/cri);
    }
    if(s >= K){
        return true;
    }else{
        return false;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        vec.pb(a);
    }
    cin >> K;
    double l = 0,h = 1000000001;
    while(1){
        double mid = (l+h)/2;
        if(abs(mid-l) < EPS){
            printf("%.10f\n",mid);
            break;
        }
        if(possible(mid)){
            l = mid;
        }else{
            h = mid;
        }
    }
    return 0;
}
0