結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 243 ms
12,964 KB
testcase_01 AC 241 ms
13,048 KB
testcase_02 AC 242 ms
12,816 KB
testcase_03 AC 228 ms
13,028 KB
testcase_04 AC 230 ms
12,840 KB
testcase_05 AC 229 ms
13,040 KB
testcase_06 AC 240 ms
12,636 KB
testcase_07 AC 238 ms
12,720 KB
testcase_08 AC 223 ms
12,296 KB
testcase_09 AC 226 ms
12,788 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++) {
		pair<double,int> p = P.top();
		P.pop();
		res[i]=p.first;
		num[p.second]++;
		p=make_pair(L[p.second]/(num[p.second]+1.0),p.second);
		
		P.push(p);
	}
	
	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