# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
365123 | 2021-02-10T23:01:59 Z | dg2004 | A Huge Tower (CEOI10_tower) | Java 11 | 0 ms | 0 KB |
import java.util.*; import java.io.*; public class Solution { static int MOD = 1000000009; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token = new StringTokenizer(in.readLine()); int n = Integer.parseInt(token.nextToken()), d = Integer.parseInt(token.nextToken()); int[] ar = new int[n]; token = new StringTokenizer(in.readLine()); for (int a = 0; a < n; a++) ar[a] = Integer.parseInt(token.nextToken()); Arrays.sort(ar); int r = 0; int ans = 1; for (int l = 0; l < n; l++) { while (r < n - 1 && ar[r + 1] - ar[l] <= d) r++; int dist = r - l + 1; ans = (int)(((long)ans * dist) % MOD); } System.out.println(ans); } }