結果

問題 No.1808 Fullgold Alchemist
ユーザー tentententen
提出日時 2022-08-09 10:07:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 1,579 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 78,076 KB
実行使用メモリ 66,636 KB
最終ジャッジ日時 2023-10-19 20:59:02
合計ジャッジ時間 13,858 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
53,404 KB
testcase_01 AC 56 ms
52,288 KB
testcase_02 AC 55 ms
53,404 KB
testcase_03 AC 55 ms
53,400 KB
testcase_04 AC 55 ms
53,344 KB
testcase_05 AC 221 ms
61,320 KB
testcase_06 AC 283 ms
62,716 KB
testcase_07 AC 255 ms
62,696 KB
testcase_08 AC 396 ms
66,636 KB
testcase_09 AC 327 ms
64,172 KB
testcase_10 AC 294 ms
66,208 KB
testcase_11 AC 339 ms
66,104 KB
testcase_12 AC 253 ms
62,560 KB
testcase_13 AC 316 ms
62,744 KB
testcase_14 AC 298 ms
62,740 KB
testcase_15 AC 310 ms
62,728 KB
testcase_16 AC 103 ms
55,164 KB
testcase_17 AC 55 ms
52,292 KB
testcase_18 AC 162 ms
57,636 KB
testcase_19 AC 81 ms
54,256 KB
testcase_20 AC 192 ms
58,928 KB
testcase_21 AC 131 ms
55,564 KB
testcase_22 AC 57 ms
53,404 KB
testcase_23 AC 121 ms
55,324 KB
testcase_24 AC 105 ms
55,080 KB
testcase_25 AC 104 ms
55,208 KB
testcase_26 AC 166 ms
57,904 KB
testcase_27 AC 188 ms
57,896 KB
testcase_28 AC 346 ms
63,884 KB
testcase_29 AC 232 ms
58,688 KB
testcase_30 AC 211 ms
58,676 KB
testcase_31 AC 301 ms
62,668 KB
testcase_32 AC 264 ms
60,580 KB
testcase_33 AC 301 ms
60,608 KB
testcase_34 AC 376 ms
64,576 KB
testcase_35 AC 274 ms
60,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int x = sc.nextInt();
        long[] values = new long[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
        }
        long left = 0;
        long right = Long.MAX_VALUE / 2;
        while (right - left > 1) {
            long m = (left + right) / 2;
            boolean enable = true;
            long remain = 0;
            for (int i = 0; i < n && enable; i++) {
                remain += values[i];
                enable = (remain / x >= m);
                remain -= x * m;
            }
            if (enable) {
                left = m;
            } else {
                right = m;
            }
        }
        System.out.println(left);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    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 String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0