結果
| 問題 |
No.68 よくある棒を切る問題 (2)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-11-17 03:53:54 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 712 ms / 5,000 ms |
| コード長 | 1,971 bytes |
| コンパイル時間 | 2,727 ms |
| コンパイル使用メモリ | 83,608 KB |
| 実行使用メモリ | 65,556 KB |
| 最終ジャッジ日時 | 2025-01-02 16:30:05 |
| 合計ジャッジ時間 | 16,801 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
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[m];
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;
}
}