This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
import java.io.*;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
class App {
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |