結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | kroton |
提出日時 | 2014-11-17 06:30:28 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 417 ms / 5,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 1,830 ms |
コンパイル使用メモリ | 66,528 KB |
実行使用メモリ | 8,788 KB |
最終ジャッジ日時 | 2023-08-30 20:21:45 |
合計ジャッジ時間 | 8,585 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 417 ms
8,632 KB |
testcase_01 | AC | 413 ms
8,472 KB |
testcase_02 | AC | 415 ms
8,488 KB |
testcase_03 | AC | 409 ms
8,600 KB |
testcase_04 | AC | 409 ms
8,428 KB |
testcase_05 | AC | 405 ms
8,788 KB |
testcase_06 | AC | 403 ms
8,252 KB |
testcase_07 | AC | 408 ms
8,468 KB |
testcase_08 | AC | 396 ms
8,368 KB |
testcase_09 | AC | 406 ms
8,364 KB |
ソースコード
#include <iostream> #include <queue> using namespace std; const int K_MAX = 500010; double res[K_MAX]; int main(){ int N; cin >> N; priority_queue<pair<double, int>> Q; for(int i=0;i<N;i++){ int L; cin >> L; Q.push(make_pair(L, 1)); } for(int k=1;k<K_MAX;k++){ auto ps = Q.top(); Q.pop(); double len = ps.first; int cut = ps.second; res[k] = len; Q.push(make_pair(len * cut / (cut + 1), cut + 1)); } int Qs; cin >> Qs; for(int i=0;i<Qs;i++){ int K; cin >> K; printf("%.15f\n", res[K]); } return 0; }