結果
| 問題 | No.68 よくある棒を切る問題 (2) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2014-11-17 03:38:08 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                RE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,971 bytes | 
| コンパイル時間 | 2,968 ms | 
| コンパイル使用メモリ | 81,984 KB | 
| 実行使用メモリ | 65,560 KB | 
| 最終ジャッジ日時 | 2025-01-02 16:28:40 | 
| 合計ジャッジ時間 | 10,803 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 6 RE * 4 | 
ソースコード
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		MyScanner sc=new MyScanner();
		int n=sc.nextInt();
		int L[]=new int[n];
		for(int i=0;i<n;i++){
			L[i]=sc.nextInt();
		}
		int m=sc.nextInt();
		int k[]=new int[n];
		for(int i=0;i<m;i++){
			k[i]=sc.nextInt();
		}
		int get[]=new int[n];
		double ans[]=new double[500001];
		PriorityQueue <connect>Q=new PriorityQueue<>();
		for(int i=0;i<n;i++){
			Q.add(new connect(L[i],i));
		}
		for(int i=1;i<500001;i++){
			connect con=Q.poll();
			ans[i]=con.a;
			get[con.b]++;
			Q.add(new connect((double)L[con.b]/(get[con.b]+1),con.b));
		}
		StringBuilder s=new StringBuilder("");
		for(int i=0;i<m;i++){
		String S=""+ans[k[i]];	
		s.append(S+"\n");
		}
		System.out.print(s);
		
	}
}
class MyScanner {
	int nextInt() {
		try {
			int c = System.in.read();
			while (c != '-' && (c < '0' || '9' < c))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			do {
				res *= 10;
				res += c - '0';
				c = System.in.read();
			} while ('0' <= c && c <= '9');
			return res;
		} catch (Exception e) {
			return -1;
		}
	}
	double nextDouble() {
		return Double.parseDouble(next());
	}
	long nextLong() {
		return Long.parseLong(next());
	}
	String next() {
		try {
			StringBuilder res = new StringBuilder("");
			int c = System.in.read();
			while (Character.isWhitespace(c))
				c = System.in.read();
			do {
				res.append((char) c);
			} while (!Character.isWhitespace(c = System.in.read()));
			return res.toString();
		} catch (Exception e) {
			return null;
		}
	}
}
class connect implements Comparable<connect> {
	double a;
	int b;
	public connect(double a,int b) {
		this.a = a;
		this.b = b;
	}
	public connect() {
	}
	@Override
	public int compareTo(connect o) {
		if(this.a>o.a)return -1;
		if(this.a==o.a)return 0;
		return 1;
	}
}
            
            
            
        