結果

問題 No.33 アメーバがたくさん
ユーザー htensaihtensai
提出日時 2020-01-15 14:26:23
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 3,888 ms
コンパイル使用メモリ 72,632 KB
実行使用メモリ 56,300 KB
最終ジャッジ日時 2023-08-30 22:39:55
合計ジャッジ時間 6,042 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
56,240 KB
testcase_01 AC 126 ms
55,728 KB
testcase_02 AC 124 ms
55,988 KB
testcase_03 AC 122 ms
55,784 KB
testcase_04 AC 123 ms
55,784 KB
testcase_05 AC 123 ms
55,628 KB
testcase_06 AC 123 ms
55,784 KB
testcase_07 AC 123 ms
56,300 KB
testcase_08 AC 123 ms
55,728 KB
testcase_09 AC 128 ms
56,268 KB
testcase_10 AC 121 ms
55,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long d = sc.nextInt();
        long t = sc.nextInt();
        int BASE = 1000000000;
        long count = 0;
        HashMap<Long, Long> map = new HashMap<>();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
        Arrays.sort(arr);
        for (int i = 0; i < n; i++) {
            long x = arr[i] + BASE;
            long mod = x % d;
            if (map.containsKey(mod)) {
                long y = map.get(mod);
                if (x - y > 2 * t * d) {
                    count += 2 * t + 1;
                } else {
                    count += (x - y) / d;
                }
            } else {
                count += 2 * t + 1;
            }
            map.put(mod, x);
        }
        System.out.println(count);
    }
}
0