Submission #326850

#TimeUsernameProblemLanguageResultExecution timeMemory
326850shliaoA Huge Tower (CEOI10_tower)Java
100 / 100
924 ms49676 KiB
import java.io.*; import java.util.*; public class tower { static int mod = 1000000009; public static void main(String[]args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken()); int D = Integer.parseInt(st.nextToken()); st = new StringTokenizer(br.readLine()); int[]blocks = new int[N]; for(int i = 0; i<N; i++) { blocks[i] = Integer.parseInt(st.nextToken()); } Arrays.sort(blocks); int[]stack = new int[N]; int j = 0; for(int i = 0; i<N; i++) { while(j<N && blocks[j]-blocks[i]<=D) j++; stack[i] = j-i; } long ans = 1; for(int i = 0; i<N; i++) { ans = (stack[i]*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...