結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー imgry22imgry22
提出日時 2014-12-28 02:32:04
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 309 ms / 5,000 ms
コード長 1,345 bytes
コンパイル時間 3,626 ms
コンパイル使用メモリ 149,784 KB
実行使用メモリ 10,396 KB
最終ジャッジ日時 2023-09-03 18:43:06
合計ジャッジ時間 7,936 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
10,288 KB
testcase_01 AC 298 ms
10,396 KB
testcase_02 AC 300 ms
10,240 KB
testcase_03 AC 295 ms
10,332 KB
testcase_04 AC 309 ms
10,336 KB
testcase_05 AC 299 ms
10,340 KB
testcase_06 AC 291 ms
9,924 KB
testcase_07 AC 301 ms
10,012 KB
testcase_08 AC 284 ms
9,504 KB
testcase_09 AC 283 ms
9,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;

#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

#define MAX_N 100000
#define MAX_Q 100000
#define MAX_K 500000

int n;
double l[MAX_N];
int q;
int k[MAX_Q];
double res[MAX_K];
int len[MAX_N];

int main()
{
  cin >> n;  rep(i, n) cin >> l[i];
  cin >> q;  rep(i, q) cin >> k[i];

  priority_queue<pair<double, int> > que;
  rep(i, n) que.push(mp(l[i], i));
  rep(i, n) len[i] = 1;
  rep(i, MAX_K){
    pair<double, int> top = que.top();  que.pop();
    res[i] = top.first;
    len[top.second] += 1;
    que.push(mp(l[top.second] / len[top.second], top.second));
  }

  rep(i, q) printf("%.15f\n", res[k[i]-1]);

  return 0;
}
0