結果
| 問題 | No.68 よくある棒を切る問題 (2) | 
| コンテスト | |
| ユーザー |  goodbaton | 
| 提出日時 | 2015-07-31 20:19:02 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,004 bytes | 
| コンパイル時間 | 825 ms | 
| コンパイル使用メモリ | 72,616 KB | 
| 実行使用メモリ | 10,652 KB | 
| 最終ジャッジ日時 | 2024-07-17 23:04:30 | 
| 合計ジャッジ時間 | 13,860 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | TLE * 1 -- * 9 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
main.cpp:38:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |     for(int i=0;i<n;i++) scanf("%d",&l[i]);
      |                          ~~~~~^~~~~~~~~~~~
main.cpp:40:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   40 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
main.cpp:45:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   45 |         scanf("%d",&k);
      |         ~~~~~^~~~~~~~~
            
            ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL
#define SIZE 10001
int n,l[200000];
bool check(double p,int k){
    ll cc=0;
    
    for(int i=0;i<n;i++)
        cc+=(int)(l[i]/p);
    
    return cc>=k;
}
int main(){
    int q,k;
    scanf("%d",&n);
    
    for(int i=0;i<n;i++) scanf("%d",&l[i]);
    
    scanf("%d",&q);
    
    double l=0,r=1e9,mid;
    
    for(int i=0;i<q;i++){
        scanf("%d",&k);
        l=0;
        r=1e9;
        
        for(int i=0;i<100;i++){
            mid = (l+r)/2;
            
            if(check(mid,k)){
                l = mid;
            }else{
                r = mid;
            }
        }
        printf("%.10lf\n",mid);
    }
    
    
    return 0;
}
            
            
            
        