結果
問題 | No.1808 Fullgold Alchemist |
ユーザー | tenten |
提出日時 | 2023-08-08 09:33:56 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 330 ms / 2,000 ms |
コード長 | 2,126 bytes |
コンパイル時間 | 4,480 ms |
コンパイル使用メモリ | 83,272 KB |
実行使用メモリ | 53,416 KB |
最終ジャッジ日時 | 2024-11-08 15:14:37 |
合計ジャッジ時間 | 12,958 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 53 ms
37,048 KB |
testcase_01 | AC | 53 ms
37,212 KB |
testcase_02 | AC | 52 ms
36,932 KB |
testcase_03 | AC | 53 ms
36,800 KB |
testcase_04 | AC | 52 ms
37,224 KB |
testcase_05 | AC | 197 ms
45,540 KB |
testcase_06 | AC | 259 ms
47,136 KB |
testcase_07 | AC | 252 ms
47,060 KB |
testcase_08 | AC | 330 ms
53,416 KB |
testcase_09 | AC | 294 ms
53,352 KB |
testcase_10 | AC | 292 ms
53,300 KB |
testcase_11 | AC | 301 ms
50,892 KB |
testcase_12 | AC | 257 ms
47,024 KB |
testcase_13 | AC | 285 ms
47,300 KB |
testcase_14 | AC | 284 ms
47,064 KB |
testcase_15 | AC | 295 ms
47,244 KB |
testcase_16 | AC | 104 ms
39,468 KB |
testcase_17 | AC | 54 ms
37,256 KB |
testcase_18 | AC | 150 ms
41,520 KB |
testcase_19 | AC | 90 ms
38,884 KB |
testcase_20 | AC | 173 ms
43,184 KB |
testcase_21 | AC | 127 ms
40,284 KB |
testcase_22 | AC | 53 ms
37,056 KB |
testcase_23 | AC | 116 ms
39,712 KB |
testcase_24 | AC | 100 ms
39,176 KB |
testcase_25 | AC | 94 ms
39,260 KB |
testcase_26 | AC | 158 ms
41,980 KB |
testcase_27 | AC | 163 ms
42,420 KB |
testcase_28 | AC | 283 ms
48,452 KB |
testcase_29 | AC | 195 ms
44,088 KB |
testcase_30 | AC | 182 ms
43,820 KB |
testcase_31 | AC | 269 ms
47,604 KB |
testcase_32 | AC | 228 ms
45,796 KB |
testcase_33 | AC | 267 ms
46,936 KB |
testcase_34 | AC | 287 ms
48,644 KB |
testcase_35 | AC | 264 ms
46,872 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); long a = sc.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } int left = 0; int right = Integer.MAX_VALUE / 2; while (right - left > 1) { int m = (left + right) / 2; boolean enable = true; long remain = 0; for (int i = 0; i < n && enable; i++) { enable = (remain + values[i] >= a * m); remain += values[i] - a * m; } if (enable) { left = m; } else { right = m; } } System.out.println(left); } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }