Submission #934216

# Submission time Handle Problem Language Result Execution time Memory
934216 2024-02-27T01:39:45 Z tkaim A Huge Tower (CEOI10_tower) Java 11
100 / 100
438 ms 70504 KB
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

class tower {
 
  public static void main(String[] args) throws IOException {
    //BufferedReader reader = new BufferedReader(new FileReader(new File("diamond.in")));
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    //PrintWriter out = new PrintWriter(new FileWriter(new File("diamond.out")));

	StringTokenizer sTokenizer = new StringTokenizer(reader.readLine());

	int numCount = Integer.parseInt(sTokenizer.nextToken());
	int difference = Integer.parseInt(sTokenizer.nextToken());

	int[] blocks = new int[numCount];

	sTokenizer = new StringTokenizer(reader.readLine());
	for(int i = 0; i < numCount; i++) {
		blocks[i] = Integer.parseInt(sTokenizer.nextToken());
	}

	Arrays.sort(blocks);
	long answer = 1;
	int upBlock = 0;
	for(int i = 0; i < numCount; i++) {
		while (upBlock < numCount - 1 && blocks[upBlock + 1] - blocks[i] <= difference) {upBlock++;}
		int multiplier = upBlock - i + 1;
		answer = ((long)multiplier * answer) % 1000000009;
	}
	System.out.println(answer);
	
  }
}
# Verdict Execution time Memory Grader output
1 Correct 48 ms 26720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 22420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 22596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 25976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 24684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 21964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 22212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 22380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 21964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 23548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 21732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 23940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 22712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 21936 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 23048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 34976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 218 ms 32988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 438 ms 37940 KB Output is correct
2 Correct 433 ms 40048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 382 ms 50216 KB Output is correct
2 Correct 345 ms 50532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 402 ms 66740 KB Output is correct
2 Correct 434 ms 70504 KB Output is correct