結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー |
|
提出日時 | 2017-12-05 11:13:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 159 ms / 5,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 65,368 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-03-03 10:58:17 |
合計ジャッジ時間 | 5,607 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:15:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | scanf("%lld", &k); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <cmath> #include <cstdio> #include <vector> using int64 = long long; int main() { int n; scanf("%d", &n); std::vector<int> a(n); for (int i = 0; i < n; ++i) { scanf("%d", &a[i]); } int64 k; scanf("%lld", &k); double left = 0, right = 1e9; for (int it = 0; it < 100; ++it) { double mid = (left + right) * 0.5; int64 cnt = 0; for (auto &&e: a) { cnt += floor(e / mid); } if (cnt >= k) left = mid; else right = mid; } printf("%.20f\n", left); return 0; }