結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | ey429 |
提出日時 | 2015-02-28 21:48:09 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 241 ms / 5,000 ms |
コード長 | 787 bytes |
コンパイル時間 | 679 ms |
コンパイル使用メモリ | 69,908 KB |
実行使用メモリ | 6,516 KB |
最終ジャッジ日時 | 2023-09-06 05:49:13 |
合計ジャッジ時間 | 9,913 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 241 ms
6,508 KB |
testcase_01 | AC | 239 ms
6,512 KB |
testcase_02 | AC | 239 ms
6,452 KB |
testcase_03 | AC | 229 ms
6,464 KB |
testcase_04 | AC | 226 ms
6,508 KB |
testcase_05 | AC | 228 ms
6,460 KB |
testcase_06 | AC | 236 ms
6,180 KB |
testcase_07 | AC | 237 ms
6,516 KB |
testcase_08 | AC | 223 ms
6,032 KB |
testcase_09 | AC | 224 ms
6,228 KB |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:45:20: warning: ‘r’ may be used uninitialized in this function [-Wmaybe-uninitialized] ans[qr[i].second]=r; ~~~~~~~~~~~~~~~~~^~
ソースコード
#include<stdio.h> #include<queue> #include<map> #include<algorithm> using namespace std; typedef pair<double,int> Pf; typedef pair<int,int> P; priority_queue<Pf> que; int L[100000]; int cnt[100000]; P qr[100000]; double ans[100000]; double F(int a,int b){return (double)a/b;} int main(){ int n,i; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&L[i]); cnt[i]=1; que.push(Pf(L[i],i)); } int m; scanf("%d",&m); for(i=0;i<m;i++){ int q; scanf("%d",&q); qr[i]=P(q,i); } sort(qr,qr+m); int s=0; double r; for(i=0;i<m;i++){ int q=qr[i].first; while(s<q){ Pf pr=que.top(); que.pop(); int t=pr.second; r=pr.first; cnt[t]++; que.push(Pf(F(L[t],cnt[t]),t)); s++; } ans[qr[i].second]=r; } for(i=0;i<m;i++)printf("%.12f\n",ans[i]); return 0; }