# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
727139 | 2023-04-20T05:27:26 Z | dn4271 | A Huge Tower (CEOI10_tower) | Java 11 | 0 ms | 0 KB |
import java.util.*; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); int n = input.nextInt(); int d = input.nextInt(); int[] blocks = new int[n]; for (int i = 0; i < n; i++) { blocks[i] = input.nextInt(); } Arrays.sort(blocks); int[] tolerance = new int[n]; tolerance[0] = 1; for (int i = 1; i < n; i++) { int j = 0; while (blocks[i] - blocks[j] > d) { j++; } tolerance[i] = i - j + 1; } int answer = 1; for (int i: tolerance) { answer = answer * i; } System.out.println(answer); } }