結果
問題 |
No.33 アメーバがたくさん
|
ユーザー |
![]() |
提出日時 | 2020-01-15 14:26:23 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 129 ms / 5,000 ms |
コード長 | 971 bytes |
コンパイル時間 | 2,410 ms |
コンパイル使用メモリ | 77,736 KB |
実行使用メモリ | 54,520 KB |
最終ジャッジ日時 | 2025-01-02 21:04:34 |
合計ジャッジ時間 | 4,661 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
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); } }