# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
367298 | 2021-02-16T20:07:59 Z | Vectorized | A Huge Tower (CEOI10_tower) | Java 11 | 0 ms | 0 KB |
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class HugeTower { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); long MOD = 1000000009; int n = Integer.parseInt(st.nextToken()), m = Integer.parseInt(st.nextToken()); int[] ar = new int[n]; st = new StringTokenizer(br.readLine()); for (int i = 0; i < n; i++) { ar[i] = Integer.parseInt(st.nextToken()); } long ans = 1; Arrays.sort(ar); int pointer = 0; for (int i = 0; i < n; i++) { for(;pointer<n && ar[pointer] - ar[i] <= m;pointer++){} // System.out.println(i + " " + pointer); ans = ans * ((long)(pointer - i)) % MOD; } System.out.println(ans); } }