結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | Pachicobue |
提出日時 | 2017-07-19 20:51:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 511 ms / 5,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 1,624 ms |
コンパイル使用メモリ | 170,360 KB |
実行使用メモリ | 17,700 KB |
最終ジャッジ日時 | 2024-04-17 04:07:18 |
合計ジャッジ時間 | 14,424 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 506 ms
17,700 KB |
testcase_01 | AC | 511 ms
17,672 KB |
testcase_02 | AC | 495 ms
17,548 KB |
testcase_03 | AC | 499 ms
17,588 KB |
testcase_04 | AC | 505 ms
17,676 KB |
testcase_05 | AC | 505 ms
17,616 KB |
testcase_06 | AC | 484 ms
16,540 KB |
testcase_07 | AC | 507 ms
17,240 KB |
testcase_08 | AC | 477 ms
16,068 KB |
testcase_09 | AC | 499 ms
16,636 KB |
ソースコード
#include <bits/stdc++.h> #define show(x) cout << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template <typename T> constexpr T INF = numeric_limits<T>::max() / 100; constexpr ll MAX = 500000; long double table[MAX + 1]; int main() { ll N; cin >> N; using pli = pair<long double, int>; vector<pli> L(N); priority_queue<pli> q; for (ll i = 0; i < N; i++) { cin >> L[i].first; L[i].second = 1; q.push(L[i]); } for (ll i = 1; i <= MAX; i++) { pli p = q.top(); q.pop(); table[i] = p.first; p.first = p.first * p.second / (p.second + 1); p.second++; q.push(p); } ll Q; cin >> Q; for (ll i = 0; i < Q; i++) { ll K; cin >> K; cout << fixed << setprecision(10) << table[K] << endl; } return 0; }