Submission #934814

# Submission time Handle Problem Language Result Execution time Memory
934814 2024-02-28T04:14:19 Z jeli26 A Huge Tower (CEOI10_tower) Java 11
35 / 100
440 ms 66972 KB
import java.io.*;
import java.util.*;

public class tower {

	static int MAX = 1000000009;

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(in.readLine());
		int n = Integer.parseInt(st.nextToken());
		int m = Integer.parseInt(st.nextToken());

		int[] blocks = new int[n];
		st = new StringTokenizer(in.readLine());
		for(int i = 0; i < n; i++) {
			blocks[i] = Integer.parseInt(st.nextToken());
		}

		Arrays.sort(blocks);

		int ans = 1;
		int r = 1;
		for(int l = 0; l < n; l++) {
			while(r < n && blocks[r] - blocks[l] <= m) {
				r++;
			}

			int mult = Math.max((r - l) % MAX, 1);
			ans = ((ans * r % MAX) - (ans * l % MAX)) % MAX;
		}

		System.out.println(ans);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 60 ms 26144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 22336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 26112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 24140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 22580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 22032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 22200 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 52 ms 22004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 22632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 50 ms 24580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 22164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 23956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 24272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 57 ms 22092 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 23312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 174 ms 32116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 228 ms 36168 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 440 ms 42740 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 367 ms 50416 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 405 ms 66972 KB Output isn't correct
2 Halted 0 ms 0 KB -