Submission #326562

#TimeUsernameProblemLanguageResultExecution timeMemory
326562shliaoA Huge Tower (CEOI10_tower)Java
30 / 100
825 ms50684 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 = N-1; for(int i = N-1; i>=0; i--) { while(j>=0 && blocks[i]-blocks[j]<=D) j--; stack[i] = i-j; } int ans = 1; for(int i = N-1; i>=0; i--) { ans = (ans*stack[i]) % 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...