結果
問題 | No.33 アメーバがたくさん |
ユーザー |
|
提出日時 | 2014-10-03 19:20:13 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 138 ms / 5,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 2,297 ms |
コンパイル使用メモリ | 79,008 KB |
実行使用メモリ | 54,412 KB |
最終ジャッジ日時 | 2024-09-24 09:53:35 |
合計ジャッジ時間 | 4,412 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
//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; } }