Submission #735260

#TimeUsernameProblemLanguageResultExecution timeMemory
735260dxfA Huge Tower (CEOI10_tower)Java
Compilation error
0 ms0 KiB
// 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 (stderr)

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