Submission #373910

#TimeUsernameProblemLanguageResultExecution timeMemory
373910jfyenA Huge Tower (CEOI10_tower)Java
85 / 100
1095 ms25128 KiB
import java.util.*; public class tower { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int D = sc.nextInt(); long mod = 1000000009; int[] blocks = new int[N]; for (int i = 0;i<N;i++) { blocks[i] = sc.nextInt(); } Arrays.sort(blocks); long[] place = new long[N]; long[] towers = new long[N]; towers[0] = 1; //place[0] = 1; int lower = 0; for (int i = 0;i<N;i++) { while(lower<i) { if(blocks[lower]+D<blocks[i]) lower++; else break; } //System.out.println(i+" "+lower); place[i] = (i-lower+1)%mod; if (i>0) towers[i] = (place[i]*towers[i-1])%mod; } System.out.println(towers[N-1]%mod); } }
#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...