結果

問題 No.68 よくある棒を切る問題 (2)
ユーザー kou6839kou6839
提出日時 2014-12-23 17:09:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,620 ms / 5,000 ms
コード長 1,060 bytes
コンパイル時間 4,445 ms
コンパイル使用メモリ 79,124 KB
実行使用メモリ 74,764 KB
最終ジャッジ日時 2023-09-02 21:52:13
合計ジャッジ時間 28,587 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,547 ms
73,136 KB
testcase_01 AC 1,519 ms
73,048 KB
testcase_02 AC 1,569 ms
73,220 KB
testcase_03 AC 1,527 ms
71,724 KB
testcase_04 AC 1,571 ms
74,764 KB
testcase_05 AC 1,620 ms
73,628 KB
testcase_06 AC 1,475 ms
72,104 KB
testcase_07 AC 1,521 ms
72,292 KB
testcase_08 AC 1,562 ms
71,940 KB
testcase_09 AC 1,521 ms
72,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;
class Pare implements Comparable{
	int moto;
	int kaisuu;
	double now;
	Pare(int x,int y){
		moto = x;
		kaisuu=y;
		now = x;
	}
	@Override
	public int compareTo(Object arg0) {
		// TODO Auto-generated method stub
		Pare o = (Pare)arg0;
		if(this.now<o.now) return 1;
		else if(this.now>o.now) return -1;
		else return 0;
	}
}
class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        PriorityQueue<Pare> que = new PriorityQueue<>();
        for(int i=0;i<n;i++){
        	int a = sc.nextInt();
        	que.add(new Pare(a,1));
        }
        double[] ans = new double[500001];
        for(int i=1;i<500001;i++){
        	Pare temp = que.poll();
        	ans[i]=temp.now;
        	temp.kaisuu++;
        	temp.now=1.0*temp.moto/temp.kaisuu;
        	que.offer(temp);
        }
        int aa = sc.nextInt();
        for(int i=0;i<aa;i++){
        	int tt = sc.nextInt();
        	System.out.println(ans[tt]);
        }
        
    }
}
0