結果
問題 |
No.67 よくある棒を切る問題 (1)
|
ユーザー |
![]() |
提出日時 | 2014-11-17 02:01:50 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 145 ms |
コンパイル使用メモリ | 29,952 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-03 10:11:09 |
合計ジャッジ時間 | 2,232 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:41:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 41 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:45:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("%d", &length[i]); | ~~~~~^~~~~~~~~~~~~~~~~~ main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 47 | 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; for(int i = 0;i < n;i++){ current_num += (int)(x[i] / mid); } 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; }