結果
問題 | No.1808 Fullgold Alchemist |
ユーザー | tenten |
提出日時 | 2023-02-22 16:59:34 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 315 ms / 2,000 ms |
コード長 | 2,364 bytes |
コンパイル時間 | 3,427 ms |
コンパイル使用メモリ | 91,268 KB |
実行使用メモリ | 53,492 KB |
最終ジャッジ日時 | 2024-07-22 18:31:27 |
合計ジャッジ時間 | 11,965 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,240 KB |
testcase_01 | AC | 51 ms
36,852 KB |
testcase_02 | AC | 53 ms
36,804 KB |
testcase_03 | AC | 52 ms
37,280 KB |
testcase_04 | AC | 52 ms
37,016 KB |
testcase_05 | AC | 191 ms
45,592 KB |
testcase_06 | AC | 258 ms
47,092 KB |
testcase_07 | AC | 250 ms
47,152 KB |
testcase_08 | AC | 314 ms
53,492 KB |
testcase_09 | AC | 295 ms
53,228 KB |
testcase_10 | AC | 284 ms
53,312 KB |
testcase_11 | AC | 294 ms
50,624 KB |
testcase_12 | AC | 254 ms
46,928 KB |
testcase_13 | AC | 293 ms
47,500 KB |
testcase_14 | AC | 273 ms
47,508 KB |
testcase_15 | AC | 306 ms
47,216 KB |
testcase_16 | AC | 102 ms
39,288 KB |
testcase_17 | AC | 54 ms
37,296 KB |
testcase_18 | AC | 143 ms
41,864 KB |
testcase_19 | AC | 80 ms
38,116 KB |
testcase_20 | AC | 182 ms
44,428 KB |
testcase_21 | AC | 125 ms
40,328 KB |
testcase_22 | AC | 52 ms
37,024 KB |
testcase_23 | AC | 103 ms
39,740 KB |
testcase_24 | AC | 98 ms
39,264 KB |
testcase_25 | AC | 102 ms
39,356 KB |
testcase_26 | AC | 158 ms
41,844 KB |
testcase_27 | AC | 175 ms
43,488 KB |
testcase_28 | AC | 306 ms
48,200 KB |
testcase_29 | AC | 200 ms
44,260 KB |
testcase_30 | AC | 176 ms
44,872 KB |
testcase_31 | AC | 279 ms
47,144 KB |
testcase_32 | AC | 232 ms
46,012 KB |
testcase_33 | AC | 266 ms
46,960 KB |
testcase_34 | AC | 315 ms
49,428 KB |
testcase_35 | AC | 259 ms
46,932 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 need = m * a; long remain = 0; for (int x : values) { if (x < need) { if (x + remain < need) { enable = false; break; } else { remain -= need - x; } } else { remain += x - need; } } 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(); } }