結果
問題 | No.33 アメーバがたくさん |
ユーザー | uafr_cs |
提出日時 | 2017-11-09 19:36:04 |
言語 | Java19 (openjdk 21) |
結果 |
AC
|
実行時間 | 135 ms / 5,000 ms |
コード長 | 1,417 bytes |
コンパイル時間 | 2,314 ms |
コンパイル使用メモリ | 78,820 KB |
実行使用メモリ | 56,220 KB |
最終ジャッジ日時 | 2023-08-15 22:25:23 |
合計ジャッジ時間 | 4,494 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 129 ms
56,120 KB |
testcase_01 | AC | 127 ms
56,084 KB |
testcase_02 | AC | 127 ms
56,072 KB |
testcase_03 | AC | 128 ms
53,508 KB |
testcase_04 | AC | 130 ms
55,948 KB |
testcase_05 | AC | 129 ms
56,024 KB |
testcase_06 | AC | 130 ms
56,068 KB |
testcase_07 | AC | 129 ms
55,932 KB |
testcase_08 | AC | 131 ms
56,220 KB |
testcase_09 | AC | 135 ms
55,764 KB |
testcase_10 | AC | 126 ms
55,908 KB |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Map.Entry; import java.util.Scanner; import java.util.TreeSet; public class Main { public static long MOD = 1000000007; public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int N = sc.nextInt(); final long D = sc.nextLong(); final long T = sc.nextLong(); HashMap<Long, TreeSet<Long>> mods = new HashMap<Long, TreeSet<Long>>(); long[] xs = new long[N]; for(int i = 0; i < N; i++){ xs[i] = sc.nextLong(); } final long min_xs = Arrays.stream(xs).min().getAsLong(); for(int i = 0; i < N; i++){ final long X = xs[i] - min_xs; final long mod = X % D; if(!mods.containsKey(mod)){ mods.put(mod, new TreeSet<Long>()); } mods.get(mod).add(X); } long answer = 0; for(final Entry<Long, TreeSet<Long>> entry : mods.entrySet()){ final long mod = entry.getKey(); final ArrayList<Long> list = new ArrayList<Long>(entry.getValue()); if(list.size() == 1){ answer += (2 * T + 1); continue; } answer += T; for(int fst = 0; fst < list.size() - 1; fst++){ final int snd = fst + 1; final long diff = (list.get(snd) - list.get(fst)) / D - 1; final long min = Math.min(diff, 2 * T); answer += min + 1; } answer += T + 1; } System.out.println(answer); } }