結果

問題 No.1808 Fullgold Alchemist
ユーザー tentententen
提出日時 2023-08-08 09:33:56
言語 Java21
(openjdk 21)
結果
AC  
実行時間 310 ms / 2,000 ms
コード長 2,126 bytes
コンパイル時間 2,474 ms
コンパイル使用メモリ 95,720 KB
実行使用メモリ 53,836 KB
最終ジャッジ日時 2024-04-26 02:49:33
合計ジャッジ時間 11,168 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
37,372 KB
testcase_01 AC 49 ms
37,060 KB
testcase_02 AC 49 ms
37,392 KB
testcase_03 AC 49 ms
37,220 KB
testcase_04 AC 50 ms
36,784 KB
testcase_05 AC 202 ms
46,108 KB
testcase_06 AC 268 ms
47,380 KB
testcase_07 AC 239 ms
47,324 KB
testcase_08 AC 310 ms
53,836 KB
testcase_09 AC 286 ms
53,828 KB
testcase_10 AC 270 ms
53,184 KB
testcase_11 AC 262 ms
51,076 KB
testcase_12 AC 220 ms
47,412 KB
testcase_13 AC 264 ms
47,640 KB
testcase_14 AC 238 ms
47,328 KB
testcase_15 AC 259 ms
47,300 KB
testcase_16 AC 95 ms
39,072 KB
testcase_17 AC 49 ms
37,256 KB
testcase_18 AC 142 ms
42,616 KB
testcase_19 AC 72 ms
38,644 KB
testcase_20 AC 158 ms
44,340 KB
testcase_21 AC 117 ms
40,128 KB
testcase_22 AC 48 ms
37,384 KB
testcase_23 AC 108 ms
39,880 KB
testcase_24 AC 98 ms
39,380 KB
testcase_25 AC 96 ms
39,152 KB
testcase_26 AC 148 ms
43,096 KB
testcase_27 AC 173 ms
43,596 KB
testcase_28 AC 269 ms
49,048 KB
testcase_29 AC 177 ms
44,988 KB
testcase_30 AC 175 ms
44,920 KB
testcase_31 AC 247 ms
47,520 KB
testcase_32 AC 240 ms
46,084 KB
testcase_33 AC 256 ms
47,308 KB
testcase_34 AC 284 ms
49,176 KB
testcase_35 AC 240 ms
47,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0