답안 #735260

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735260 2023-05-03T18:58:26 Z dxf A Huge Tower (CEOI10_tower) Java 11
컴파일 오류
0 ms 0 KB
// Source: https://usaco.guide/general/io

import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer st = new StringTokenizer(r.readLine());
		int n = Integer.parseInt(st.nextToken());
		int d = Integer.parseInt(st.nextToken());
		
		int[] sizes = new int[n];
		st = new StringTokenizer(r.readLine());
		for (int i = 0; i < n; i++) {
			sizes[i] = Integer.parseInt(st.nextToken());
		}
		long[] former = new long[n];
		former[0] = 1; 
		Arrays.sort(sizes);
		for (int i = 1; i < n; i++) {
			long count = 1;
			int loc = i-1;;
			while (loc >= 0 && sizes[loc]+d >= sizes[i]) {
				count ++;
				loc--;
			}
			former[i] = ((long) former[i-1]) * count;
		}
	
		
		System.out.println(former[n-1]);
	}
}

Compilation message

tower.java:6: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
1 error