結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
uafr_cs
|
| 提出日時 | 2017-11-09 17:25:53 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,334 bytes |
| コンパイル時間 | 2,302 ms |
| コンパイル使用メモリ | 80,004 KB |
| 実行使用メモリ | 41,476 KB |
| 最終ジャッジ日時 | 2024-11-24 07:28:16 |
| 合計ジャッジ時間 | 4,414 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 8 |
ソースコード
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>>();
for(int i = 0; i < N; i++){
final long X = sc.nextLong();
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;
//System.out.println(answer);
for(int fst = 0; fst < list.size() - 1; fst++){
final int snd = fst + 1;
final long diff = (list.get(snd) - list.get(fst)) / D;
final long min = Math.min(diff, 2 * T);
//System.out.println(min);
answer += Math.min(diff, 2 * T);
}
answer += T;
}
System.out.println(answer);
}
}
uafr_cs