結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー 👑 kmjpkmjp
提出日時 2014-11-17 00:25:16
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 249 ms / 5,000 ms
コード長 1,058 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 151,208 KB
実行使用メモリ 13,052 KB
最終ジャッジ日時 2023-08-30 08:46:53
合計ジャッジ時間 10,270 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 245 ms
12,872 KB
testcase_01 AC 249 ms
13,048 KB
testcase_02 AC 246 ms
12,848 KB
testcase_03 AC 232 ms
12,904 KB
testcase_04 AC 229 ms
12,856 KB
testcase_05 AC 234 ms
13,052 KB
testcase_06 AC 240 ms
12,612 KB
testcase_07 AC 242 ms
12,604 KB
testcase_08 AC 228 ms
12,312 KB
testcase_09 AC 229 ms
12,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<to;x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
ll L[300000];
int num[500005];
double res[500005];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	priority_queue<pair<double,int> > P;
	
	FOR(i,N) cin>>L[i], P.push(make_pair(L[i],i));
	
	for(i=1;i<=500000;i++) {
		res[i] = P.top().first;
		j=P.top().second;
		P.pop();
		num[j]++;
		P.push(make_pair(L[j]/(num[j]+1.0),j));
	}
	
	cin>>Q;
	while(Q--) cin>>x, _P("%.12lf\n",res[x]);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0