結果

問題 No.1808 Fullgold Alchemist
ユーザー tentententen
提出日時 2022-01-20 10:44:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 1,635 bytes
コンパイル時間 4,422 ms
コンパイル使用メモリ 77,108 KB
実行使用メモリ 52,856 KB
最終ジャッジ日時 2024-05-02 20:19:17
合計ジャッジ時間 11,395 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
36,616 KB
testcase_01 AC 53 ms
36,508 KB
testcase_02 AC 53 ms
36,744 KB
testcase_03 AC 53 ms
36,576 KB
testcase_04 AC 53 ms
36,720 KB
testcase_05 AC 208 ms
45,620 KB
testcase_06 AC 275 ms
46,724 KB
testcase_07 AC 256 ms
46,680 KB
testcase_08 AC 317 ms
52,780 KB
testcase_09 AC 304 ms
52,692 KB
testcase_10 AC 291 ms
52,856 KB
testcase_11 AC 299 ms
50,080 KB
testcase_12 AC 257 ms
46,588 KB
testcase_13 AC 278 ms
46,900 KB
testcase_14 AC 281 ms
47,108 KB
testcase_15 AC 291 ms
46,772 KB
testcase_16 AC 102 ms
38,700 KB
testcase_17 AC 55 ms
36,848 KB
testcase_18 AC 157 ms
42,116 KB
testcase_19 AC 88 ms
38,260 KB
testcase_20 AC 173 ms
42,936 KB
testcase_21 AC 125 ms
39,784 KB
testcase_22 AC 53 ms
36,880 KB
testcase_23 AC 118 ms
39,244 KB
testcase_24 AC 97 ms
38,596 KB
testcase_25 AC 94 ms
38,808 KB
testcase_26 AC 150 ms
42,032 KB
testcase_27 AC 182 ms
43,004 KB
testcase_28 AC 293 ms
48,472 KB
testcase_29 AC 208 ms
44,576 KB
testcase_30 AC 206 ms
43,328 KB
testcase_31 AC 266 ms
47,028 KB
testcase_32 AC 232 ms
45,048 KB
testcase_33 AC 276 ms
46,824 KB
testcase_34 AC 306 ms
48,296 KB
testcase_35 AC 250 ms
46,460 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();
        long x = sc.nextInt();
        int[] counts = new int[n];
        for (int i = 0; i < n; i++) {
            counts[i] = sc.nextInt();
        }
        int left = 0;
        int right = Integer.MAX_VALUE / 2;
        while (right - left > 1) {
            int m = (left + right) / 2;
            long y = m * x;
            boolean ok = true;
            long remain = 0;
            for (int i = 0; i < n; i++) {
                if (remain + counts[i] < y) {
                    ok = false;
                    break;
                }
                remain += counts[i] - y;
            }
            if (ok) {
                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 {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0