結果
| 問題 |
No.33 アメーバがたくさん
|
| コンテスト | |
| ユーザー |
ぴろず
|
| 提出日時 | 2014-12-18 13:11:23 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 143 ms / 5,000 ms |
| コード長 | 1,016 bytes |
| コンパイル時間 | 2,611 ms |
| コンパイル使用メモリ | 79,688 KB |
| 実行使用メモリ | 54,328 KB |
| 最終ジャッジ日時 | 2024-09-24 10:00:34 |
| 合計ジャッジ時間 | 4,457 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
package no033;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = sc.nextInt();
int t = sc.nextInt();
HashMap<Integer,ArrayList<Integer>> hm = new HashMap<>();
for(int i=0;i<n;i++) {
int x = sc.nextInt() + 1000000000;
int r = x % d;
if (hm.containsKey(r)) {
hm.get(r).add((x-r)/d);
}else{
ArrayList<Integer> al = new ArrayList<>();
al.add((x-r)/d);
hm.put(r, al);
}
}
long ans = 0;
for(Entry<Integer,ArrayList<Integer>> e:hm.entrySet()) {
ArrayList<Integer> al = e.getValue();
Collections.sort(al);
int right = -(1<<30);
for(int x: al) {
if (right < x - t) {
ans += t * 2 + 1;
}else{
ans += x + t - right;
}
right = x + t;
}
}
System.out.println(ans);
}
}
ぴろず