結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-16 11:04:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 39 ms / 5,000 ms |
| コード長 | 568 bytes |
| コンパイル時間 | 444 ms |
| コンパイル使用メモリ | 27,648 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-03 11:16:12 |
| 合計ジャッジ時間 | 2,270 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:24:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
24 | scanf("%d", L+i);
| ~~~~~^~~~~~~~~~~
main.cpp:27:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%lld", &k);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
int n;
int L[200000];
long long int k;
int p(double x){
long long int c = 0;
int i;
double ix = 1.0 / x;
for(i=0;i<n;i++){
// c += (int) (L[i] / x);
c += (int) (L[i] * ix);
}
return c >= k;
}
int main(){
int i;
long long int s = 0;
double lb, ub;
scanf("%d", &n);
for(i=0;i<n;i++){
scanf("%d", L+i);
s += L[i];
}
scanf("%lld", &k);
ub = s/k+1;
lb = 0;
while((ub-lb)*(1ULL<<32) > ub){
double m = (lb + ub) / 2;
if(p(m)) lb = m;
else ub = m;
}
printf("%.20f\n", lb);
return 0;
}