Submission #542296

# Submission time Handle Problem Language Result Execution time Memory
542296 2022-03-26T05:27:55 Z RishabhPrabhu A Huge Tower (CEOI10_tower) Java 11
95 / 100
1000 ms 30208 KB
import java.util.*;
import java.io.*;
 
public class tower {
    public static void main(String[] args) throws IOException {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int d = in.nextInt();
        int[] b = new int[n];
        for(int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }
        Arrays.sort(b);
        long ans = 1;
        int lowerP = 0;
        for(int i = 1; i < n; i++) {
            while(b[lowerP] < b[i]-d) {
                lowerP++;
            }
            ans *= (i - lowerP + 1);
            ans %= 1000000009;
        }
        System.out.println(ans);
        System.out.close();
    }
} 
# Verdict Execution time Memory Grader output
1 Correct 98 ms 10564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 10140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 10328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 95 ms 10204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 10176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 10096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 10256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 10240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 98 ms 10140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 10124 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 10104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 10184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 10372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 241 ms 12600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 363 ms 20644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 571 ms 23148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 892 ms 25232 KB Output is correct
2 Correct 874 ms 24636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 933 ms 27120 KB Output is correct
2 Correct 885 ms 27180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1084 ms 30208 KB Time limit exceeded
2 Halted 0 ms 0 KB -