結果
| 問題 |
No.67 よくある棒を切る問題 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-16 10:48:13 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 58 ms / 5,000 ms |
| コード長 | 461 bytes |
| コンパイル時間 | 168 ms |
| コンパイル使用メモリ | 27,520 KB |
| 実行使用メモリ | 8,604 KB |
| 最終ジャッジ日時 | 2025-03-03 11:16:12 |
| 合計ジャッジ時間 | 2,696 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:19:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
19 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:20:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | for(i=0;i<n;i++) scanf("%d", L+i);
| ~~~~~^~~~~~~~~~~
main.cpp:21:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
21 | 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;
for(i=0;i<n;i++){
c += (int) (L[i] / x);
}
return c >= k;
}
int main(){
int i;
double lb, ub;
scanf("%d", &n);
for(i=0;i<n;i++) scanf("%d", L+i);
scanf("%lld", &k);
ub = 1000000001;
lb = 0;
for(i=0;i<100;i++){
double m = (lb + ub) / 2;
if(p(m)) lb = m;
else ub = m;
}
printf("%.20f\n", lb);
return 0;
}