結果

問題 No.1808 Fullgold Alchemist
ユーザー tentententen
提出日時 2023-02-22 16:59:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 281 ms / 2,000 ms
コード長 2,364 bytes
コンパイル時間 2,745 ms
コンパイル使用メモリ 89,912 KB
実行使用メモリ 63,508 KB
最終ジャッジ日時 2023-09-30 00:33:55
合計ジャッジ時間 12,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,380 KB
testcase_01 AC 41 ms
49,328 KB
testcase_02 AC 41 ms
49,252 KB
testcase_03 AC 42 ms
49,412 KB
testcase_04 AC 41 ms
49,452 KB
testcase_05 AC 193 ms
56,300 KB
testcase_06 AC 237 ms
57,604 KB
testcase_07 AC 228 ms
58,000 KB
testcase_08 AC 268 ms
63,508 KB
testcase_09 AC 256 ms
62,764 KB
testcase_10 AC 247 ms
61,036 KB
testcase_11 AC 253 ms
60,748 KB
testcase_12 AC 226 ms
57,504 KB
testcase_13 AC 266 ms
57,500 KB
testcase_14 AC 250 ms
57,456 KB
testcase_15 AC 262 ms
58,040 KB
testcase_16 AC 86 ms
50,612 KB
testcase_17 AC 42 ms
49,660 KB
testcase_18 AC 136 ms
55,748 KB
testcase_19 AC 65 ms
50,808 KB
testcase_20 AC 157 ms
56,080 KB
testcase_21 AC 111 ms
52,332 KB
testcase_22 AC 45 ms
49,344 KB
testcase_23 AC 103 ms
51,972 KB
testcase_24 AC 83 ms
52,208 KB
testcase_25 AC 87 ms
52,212 KB
testcase_26 AC 144 ms
55,872 KB
testcase_27 AC 155 ms
55,180 KB
testcase_28 AC 281 ms
58,964 KB
testcase_29 AC 188 ms
53,616 KB
testcase_30 AC 178 ms
57,976 KB
testcase_31 AC 241 ms
57,452 KB
testcase_32 AC 239 ms
56,308 KB
testcase_33 AC 249 ms
57,456 KB
testcase_34 AC 271 ms
59,080 KB
testcase_35 AC 231 ms
57,552 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 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();
    }
    
}
0