結果
問題 | No.68 よくある棒を切る問題 (2) |
ユーザー | kou6839 |
提出日時 | 2014-12-23 17:09:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 1,864 ms / 5,000 ms |
コード長 | 1,060 bytes |
コンパイル時間 | 2,552 ms |
コンパイル使用メモリ | 78,792 KB |
実行使用メモリ | 78,652 KB |
最終ジャッジ日時 | 2024-06-12 04:07:32 |
合計ジャッジ時間 | 30,245 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
ソースコード
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]); } } }