結果
問題 | No.67 よくある棒を切る問題 (1) |
ユーザー | uafr_cs |
提出日時 | 2015-09-07 02:15:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,828 ms / 5,000 ms |
コード長 | 1,944 bytes |
コンパイル時間 | 2,357 ms |
コンパイル使用メモリ | 81,096 KB |
実行使用メモリ | 70,620 KB |
最終ジャッジ日時 | 2024-04-25 23:32:01 |
合計ジャッジ時間 | 26,735 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 418 ms
65,356 KB |
testcase_01 | AC | 127 ms
54,212 KB |
testcase_02 | AC | 352 ms
58,924 KB |
testcase_03 | AC | 470 ms
61,840 KB |
testcase_04 | AC | 562 ms
64,136 KB |
testcase_05 | AC | 531 ms
64,252 KB |
testcase_06 | AC | 568 ms
64,168 KB |
testcase_07 | AC | 607 ms
70,560 KB |
testcase_08 | AC | 546 ms
66,192 KB |
testcase_09 | AC | 564 ms
66,284 KB |
testcase_10 | AC | 539 ms
64,912 KB |
testcase_11 | AC | 541 ms
62,156 KB |
testcase_12 | AC | 515 ms
66,048 KB |
testcase_13 | AC | 569 ms
70,272 KB |
testcase_14 | AC | 584 ms
70,200 KB |
testcase_15 | AC | 542 ms
68,428 KB |
testcase_16 | AC | 1,788 ms
64,080 KB |
testcase_17 | AC | 1,828 ms
68,488 KB |
testcase_18 | AC | 1,797 ms
64,100 KB |
testcase_19 | AC | 1,764 ms
68,764 KB |
testcase_20 | AC | 1,811 ms
70,620 KB |
testcase_21 | AC | 1,758 ms
66,180 KB |
testcase_22 | AC | 511 ms
66,192 KB |
testcase_23 | AC | 1,673 ms
62,308 KB |
testcase_24 | AC | 116 ms
53,328 KB |
testcase_25 | AC | 177 ms
54,544 KB |
testcase_26 | AC | 149 ms
54,428 KB |
testcase_27 | AC | 142 ms
54,576 KB |
testcase_28 | AC | 293 ms
57,716 KB |
testcase_29 | AC | 245 ms
57,276 KB |
testcase_30 | AC | 178 ms
54,612 KB |
ソースコード
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); long[] input = new long[N]; for(int i = 0; i < N; i++){ input[i] = sc.nextLong(); } final long K = sc.nextLong(); final double EPS = 1e-10; double upper = Arrays.stream(input).max().getAsLong(); double lower = (double)(Arrays.stream(input).min().getAsLong()) / K; int loops = 0; while(upper > lower + EPS && loops < 1000){ final double middle = upper / 2 + lower / 2; //System.out.printf("%.12f %.12f %.12f \n", upper, upper - lower, middle); long count = 0; for(int i = 0; i < N; i++){ count += input[i] / middle; } if(count >= K){ lower = middle; }else{ upper = middle; } loops++; } System.out.printf("%.12f\n", lower); } public static class Scanner implements Closeable { private BufferedReader br; private StringTokenizer tok; public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is)); } private void getLine() throws IOException { while (!hasNext()) { tok = new StringTokenizer(br.readLine()); } } private boolean hasNext() { return tok != null && tok.hasMoreTokens(); } public String next() throws IOException { getLine(); return tok.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public void close() throws IOException { br.close(); } } }