結果

問題 No.33 アメーバがたくさん
ユーザー ぴろずぴろず
提出日時 2014-12-18 13:08:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 79,996 KB
実行使用メモリ 57,744 KB
最終ジャッジ日時 2023-10-24 17:43:12
合計ジャッジ時間 4,476 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,388 KB
testcase_01 AC 135 ms
57,376 KB
testcase_02 AC 134 ms
57,556 KB
testcase_03 AC 133 ms
57,392 KB
testcase_04 AC 134 ms
57,432 KB
testcase_05 AC 138 ms
57,424 KB
testcase_06 WA -
testcase_07 AC 135 ms
57,608 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 136 ms
57,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no033;

import java.util.ArrayList;
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();
			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);
	}

}
0