結果

問題 No.33 アメーバがたくさん
ユーザー scachescache
提出日時 2014-10-03 19:08:14
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,032 bytes
コンパイル時間 3,600 ms
コンパイル使用メモリ 78,796 KB
実行使用メモリ 57,620 KB
最終ジャッジ日時 2023-10-24 17:40:00
合計ジャッジ時間 5,611 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
57,564 KB
testcase_01 AC 120 ms
57,352 KB
testcase_02 AC 109 ms
56,252 KB
testcase_03 AC 117 ms
57,488 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 118 ms
57,572 KB
testcase_07 AC 122 ms
57,420 KB
testcase_08 AC 127 ms
57,580 KB
testcase_09 WA -
testcase_10 AC 110 ms
56,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//package yukicoder;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 * yukicoder no.33
 * @author scache
 *
 */
public class Main {
	public static void main(String[] args) {
		Main p = new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long d = sc.nextLong();
		long t = sc.nextLong();
		
		long[] x = new long[n];
		for(int i=0;i<n;i++)
			x[i] = sc.nextLong()+1000000000;
		
		System.out.println(solve(d, t, x));
	}

	public long solve(long d, long t, long[] x) {
		Arrays.sort(x);
		boolean[] isDone = new boolean[x.length];
		
		long res = 0;
		for(int i=0;i<x.length;i++){
			if(isDone[i])
				continue;
			
			isDone[i] = true;
			long r = x[i]%d;
			ArrayList<Long> seq = new ArrayList<Long>() ;
			seq.add(x[i]);
			for(int j=i+1;j<x.length;j++){
				if(x[j]%d==r && x[j]-x[i]<=2*d*t){
					seq.add(x[j]);
					isDone[j] = true;
				}
			}
			
			res += (seq.get(seq.size()-1)+d*t - (seq.get(0)-d*t))/d + 1;
			
		}
		
		return res;
	}

}
0