結果
| 問題 | No.68 よくある棒を切る問題 (2) |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-06-13 21:59:24 |
| 言語 | C++17(clang) (17.0.6 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 389 ms / 5,000 ms |
| コード長 | 1,100 bytes |
| 記録 | |
| コンパイル時間 | 989 ms |
| コンパイル使用メモリ | 142,424 KB |
| 実行使用メモリ | 9,512 KB |
| 最終ジャッジ日時 | 2024-06-22 08:28:27 |
| 合計ジャッジ時間 | 10,804 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
struct Node {
int id;
int cnt;
double length;
Node(int id = -1, int cnt = 0, double length = -1) {
this->id = id;
this->cnt = cnt;
this->length = length;
}
bool operator>(const Node &n) const {
return length < n.length;
}
};
int main() {
int N;
cin >> N;
int L[N];
priority_queue <Node, vector<Node>, greater<Node>> pque;
for (int i = 0; i < N; ++i) {
cin >> L[i];
pque.push(Node(i, 1, L[i]));
}
double ans[500001];
for (int i = 1; i <= 500000; ++i) {
Node node = pque.top();
pque.pop();
ans[i] = node.length;
double new_length = L[node.id] * 1.0 / (node.cnt + 1);
pque.push(Node(node.id, node.cnt + 1, new_length));
}
int Q;
cin >> Q;
for (int i = 0; i < Q; ++i) {
int k;
cin >> k;
cout << fixed << setprecision(10) << ans[k] << endl;
}
return 0;
}
siman