結果

問題 No.67 よくある棒を切る問題 (1)
ユーザー cielciel
提出日時 2014-11-17 00:04:57
言語 C++11
(gcc 13.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 450 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 36,864 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-21 12:41:56
合計ジャッジ時間 4,793 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:10:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%lf",&v[i]);
      |                 ~~~~~^~~~~~~~~~~~~
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%lld",&k);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <vector>
#include <cstdio>
int main(){
	int n;
	long long k;
	double mi=0,ma=0;
	scanf("%d",&n);
	std::vector<double>v(n);
	for(int i=0;i<n;i++){
		scanf("%lf",&v[i]);
		if(ma<v[i])ma=v[i];
	}
	scanf("%lld",&k);
	//for(;mi+1e-9<ma;){
	for(int x=0;x<50;x++){
		long long _n=0;
		double h=(mi+ma)/2;
		for(int i=0;i<n;i++){
			_n+=v[i]/h;
		}
		if(_n>=k){
			mi=h;
		}else{
			ma=h;
		}
	}
	printf("%.14f\n",mi);
}
0