Submission #542301

# Submission time Handle Problem Language Result Execution time Memory
542301 2022-03-26T05:31:53 Z RishabhPrabhu A Huge Tower (CEOI10_tower) Java 11
95 / 100
1000 ms 24620 KB
import java.util.Scanner;
import java.util.Arrays;
public class tower {
    public static void main(String[] args) {
        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);
    }
}
# Verdict Execution time Memory Grader output
1 Correct 102 ms 10028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 10172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 10088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 10204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 106 ms 10012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 10148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 9988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 10052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 10024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 111 ms 10016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 10148 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 10272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 112 ms 10472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 237 ms 12376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 361 ms 20668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 565 ms 23044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 917 ms 24260 KB Output is correct
2 Correct 925 ms 23852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 995 ms 24552 KB Output is correct
2 Correct 927 ms 24620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1073 ms 20048 KB Time limit exceeded
2 Halted 0 ms 0 KB -