結果

問題 No.33 アメーバがたくさん
ユーザー GrenacheGrenache
提出日時 2016-03-12 20:58:50
言語 Java19
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 1,222 bytes
コンパイル時間 5,199 ms
コンパイル使用メモリ 79,444 KB
実行使用メモリ 57,776 KB
最終ジャッジ日時 2023-10-24 20:16:29
合計ジャッジ時間 6,945 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,240 KB
testcase_01 AC 129 ms
57,776 KB
testcase_02 AC 117 ms
56,376 KB
testcase_03 AC 131 ms
57,248 KB
testcase_04 AC 128 ms
57,284 KB
testcase_05 AC 129 ms
57,504 KB
testcase_06 AC 132 ms
57,664 KB
testcase_07 AC 134 ms
57,512 KB
testcase_08 AC 133 ms
57,576 KB
testcase_09 AC 135 ms
57,248 KB
testcase_10 AC 129 ms
57,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class Main_yukicoder33 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int d = sc.nextInt();
        int t = sc.nextInt();
        int[] x = new int[n];
        Map<Integer, Set<Integer>> hm = new HashMap<>();
        for (int i = 0; i < n; i++) {
        	x[i] = sc.nextInt();
        	int mod = (x[i] % d + d) % d;

        	if (hm.containsKey(mod)) {
        		hm.get(mod).add(x[i]);
        	} else {
        		Set<Integer> tmp = new TreeSet<>();
        		tmp.add(x[i]);
        		hm.put(mod, tmp);
        	}
        }

        long ret = 0;
        for (Set<Integer> hs : hm.values()) {
        	long tmp = 0;
        	long prev = Long.MIN_VALUE;
        	for (int e : hs) {
        		long r = e + (long)d * t;
        		long l = e - (long)d * t;
        		if (l > prev) {
        			tmp++;
        		} else {
        			l = prev;
        		}

        		tmp += (r - l) / d;
        		prev = r;
        	}

        	ret += tmp;
        }

        System.out.println(ret);

        sc.close();
    }
}
0