結果

問題 No.33 アメーバがたくさん
ユーザー tentententen
提出日時 2020-11-30 12:23:43
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 4,101 ms
コンパイル使用メモリ 76,296 KB
実行使用メモリ 57,828 KB
最終ジャッジ日時 2023-10-11 02:49:05
合計ジャッジ時間 6,466 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
57,828 KB
testcase_01 AC 123 ms
56,176 KB
testcase_02 AC 123 ms
54,000 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 126 ms
56,252 KB
testcase_09 WA -
testcase_10 AC 122 ms
56,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static int BASE = 1000000000;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		long t = sc.nextInt();
		int[] point = new int[n];
		for (int i = 0; i < n; i++) {
		    point[i] = sc.nextInt() + BASE;
		}
		Arrays.sort(point);
		HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
		for (int x : point) {
		    if (!map.containsKey(x % d)) {
		        map.put(x % d, new ArrayList<>());
		    }
		    map.get(x % d).add(x / d);
		}
		long ans = 0;
		for (ArrayList<Integer> list : map.values()) {
		    ans += t * 2 + 1;
		    for (int i = 0; i < list.size() - 1; i++) {
		        ans += Math.min(list.get(i + 1) - list.get(i), t);
		    }
 		}
		System.out.println(ans);
	}
}

0