結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
![]() |
提出日時 | 2014-11-17 02:16:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 956 bytes |
コンパイル時間 | 203 ms |
コンパイル使用メモリ | 30,336 KB |
実行使用メモリ | 8,604 KB |
最終ジャッジ日時 | 2025-03-03 10:11:24 |
合計ジャッジ時間 | 2,408 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:42:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 42 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 46 | scanf("%d", &length[i]); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:48:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%lld", &k); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<stdlib.h> int comp(const void *a, const void *b){ if(*(int *)a < *(int *)b){ return 1; } else if(*(int *)a == *(int *)b){ return 0; } return -1; } double binary_search(int n, int x[], long long k){ double l = 0, r = 1000000000; for(int aiueo = 0;aiueo < 75;aiueo++){ long long current_num = 0; double mid = (l + r) / 2.0; double d = 1 / mid; for(int i = 0;i < n;i++){ current_num += (int)(x[i] * d); } if(k <= current_num){ l = mid; } else{ r = mid; } } return l; } int main(){ int n; long long k; int length[200000]; scanf("%d", &n); for(int i = 0;i < n;i++){ scanf("%d", &length[i]); } scanf("%lld", &k); printf("%f\n", binary_search(n, length, k)); return 0; }