Submission #927540

#TimeUsernameProblemLanguageResultExecution timeMemory
927540ay136416A Huge Tower (CEOI10_tower)Java
100 / 100
518 ms94500 KiB
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class tower { final static long MOD = 1_000_000_009; public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] tokens = br.readLine().split(" "); final int N = Integer.parseInt(tokens[0]); final int D = Integer.parseInt(tokens[1]); int[] blocks = new int[N]; tokens = br.readLine().split(" "); for (int i = 0; i<N; i++) { blocks[i]=Integer.parseInt(tokens[i]); } Arrays.sort(blocks); long ans = 1; int right = 0; for (int left = 0; left<N; left++) { while (right<N-1 && blocks[right+1]-blocks[left]<=D) right++; ans *= (right-left+1); ans %= MOD; } System.out.println(ans); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...