結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
|
提出日時 | 2018-06-16 10:55:33 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 43 ms / 5,000 ms |
コード長 | 515 bytes |
コンパイル時間 | 383 ms |
コンパイル使用メモリ | 25,168 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-03 11:16:09 |
合計ジャッジ時間 | 2,522 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:20:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | scanf("%d", &n); | ^~~~~~~~~~~~~~~ main.c:22:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | scanf("%d", L+i); | ^~~~~~~~~~~~~~~~ main.c:25:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | 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; 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; }