Submission #391075

# Submission time Handle Problem Language Result Execution time Memory
391075 2021-04-17T19:25:42 Z yu_lim A Huge Tower (CEOI10_tower) Java 11
30 / 100
716 ms 45532 KB
import java.util.*;
import java.io.*;

public class tower {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		StringTokenizer str = new StringTokenizer(br.readLine());
		int N = Integer.parseInt(str.nextToken());
		int D = Integer.parseInt(str.nextToken());
		int M = 1_000_000_007;

		int[] blocks = new int[N];
		str = new StringTokenizer(br.readLine());
		for (int i = 0; i < N; i++)
			blocks[i] = Integer.parseInt(str.nextToken());
		br.close();

		Arrays.sort(blocks);
		long[] towers = new long[N];
		towers[0] = 1;
		int prev = 0;
		for (int i = 0; i < N; i++) {
			while (prev < i) {
				if (blocks[prev] + D < blocks[i])
					prev++;
				else
					break;
			}
			// # of blocks <= i that can't stack on i
			if (i > 0)
				towers[i] = (((i - prev + 1) % M) * towers[i - 1]) % M;
		}
		System.out.println(towers[N - 1] % M);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 76 ms 8876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 8504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8472 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8312 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8252 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 8280 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 8592 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 8320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 8372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 8304 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 8392 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 8336 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 103 ms 9232 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 281 ms 17116 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 351 ms 19372 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 716 ms 23572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 593 ms 33164 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 643 ms 45532 KB Output isn't correct
2 Halted 0 ms 0 KB -