結果
問題 |
No.33 アメーバがたくさん
|
ユーザー |
![]() |
提出日時 | 2020-11-30 12:23:43 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 813 bytes |
コンパイル時間 | 3,471 ms |
コンパイル使用メモリ | 80,168 KB |
実行使用メモリ | 56,436 KB |
最終ジャッジ日時 | 2024-09-13 02:20:08 |
合計ジャッジ時間 | 4,522 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 6 |
ソースコード
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); } }