# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
934813 | 2024-02-28T04:13:42 Z | jeli26 | A Huge Tower (CEOI10_tower) | Java 11 | 0 ms | 0 KB |
import java.io.*; import java.util.*; public class Main { static int MAX = 1000000009; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(in.readLine()); int n = Integer.parseInt(st.nextToken()); int m = Integer.parseInt(st.nextToken()); int[] blocks = new int[n]; st = new StringTokenizer(in.readLine()); for(int i = 0; i < n; i++) { blocks[i] = Integer.parseInt(st.nextToken()); } Arrays.sort(blocks); int ans = 1; int r = 1; for(int l = 0; l < n; l++) { while(r < n && blocks[r] - blocks[l] <= m) { r++; } int mult = Math.max((r - l) % MAX, 1); ans = ((ans * r % MAX) - (ans * l % MAX)) % MAX; } System.out.println(ans); } }