結果
問題 |
No.33 アメーバがたくさん
|
ユーザー |
![]() |
提出日時 | 2020-11-30 12:25:34 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 817 bytes |
コンパイル時間 | 2,756 ms |
コンパイル使用メモリ | 80,200 KB |
実行使用メモリ | 54,484 KB |
最終ジャッジ日時 | 2024-09-13 02:20:22 |
合計ジャッジ時間 | 4,561 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 8 WA * 3 |
ソースコード
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 * 2); } } System.out.println(ans); } }