結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
57,364 KB
testcase_01 AC 120 ms
57,540 KB
testcase_02 AC 118 ms
57,412 KB
testcase_03 AC 117 ms
57,320 KB
testcase_04 AC 119 ms
57,488 KB
testcase_05 AC 119 ms
56,996 KB
testcase_06 AC 120 ms
57,644 KB
testcase_07 AC 119 ms
57,380 KB
testcase_08 AC 122 ms
55,672 KB
testcase_09 AC 126 ms
57,744 KB
testcase_10 AC 119 ms
57,556 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]);
			
			int curMax = i;
			for(int j=i+1;j<x.length;j++){
				if(x[j]%d==r && x[j]-x[curMax]<=2*d*t){
					seq.add(x[j]);
					isDone[j] = true;
					curMax = j;
				}
			}
			
			res += (seq.get(seq.size()-1)+d*t - (seq.get(0)-d*t))/d + 1;

			
		}
		
		return res;
	}

}
0