結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | kimiyuki |
提出日時 | 2016-02-19 13:53:17 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 283 ms / 5,000 ms |
コード長 | 844 bytes |
コンパイル時間 | 1,241 ms |
コンパイル使用メモリ | 70,988 KB |
実行使用メモリ | 8,904 KB |
最終ジャッジ日時 | 2023-10-23 18:26:33 |
合計ジャッジ時間 | 10,214 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 283 ms
8,904 KB |
testcase_01 | AC | 282 ms
8,904 KB |
testcase_02 | AC | 283 ms
8,904 KB |
testcase_03 | AC | 268 ms
8,904 KB |
testcase_04 | AC | 270 ms
8,904 KB |
testcase_05 | AC | 268 ms
8,904 KB |
testcase_06 | AC | 276 ms
8,828 KB |
testcase_07 | AC | 280 ms
8,868 KB |
testcase_08 | AC | 254 ms
8,800 KB |
testcase_09 | AC | 262 ms
8,840 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstdio> #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) typedef long long ll; using namespace std; struct rational_t { int p, q; }; bool operator < (rational_t a, rational_t b) { return a.p *(ll) b.q < b.p *(ll) a.q; } int main() { int n; cin >> n; vector<int> ls(n); repeat (i,n) cin >> ls[i]; int q; cin >> q; vector<int> k(q); repeat (i,q) cin >> k[i]; int max_k = *max_element(k.begin(), k.end()); vector<double> a(max_k+1); priority_queue<rational_t> que; for (int l : ls) que.push((rational_t) { l, 1 }); repeat (i,max_k) { rational_t r = que.top(); que.pop(); a[i+1] = r.p /(double) r.q; ++ r.q; que.push(r); } repeat (i,q) printf("%.14lf\n", a[k[i]]); return 0; }