Submission #713681

#TimeUsernameProblemLanguageResultExecution timeMemory
713681hexA Huge Tower (CEOI10_tower)Java
100 / 100
651 ms50872 KiB
import java.io.*; import java.util.*; public class tower { static final long MOD = (long) (1e9 + 9); public static void main (String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter out = new PrintWriter(System.out); StringTokenizer st = new StringTokenizer(reader.readLine()); int N = Integer.parseInt(st.nextToken()); int diff = Integer.parseInt(st.nextToken()); int[] sizes = new int[N]; st = new StringTokenizer(reader.readLine()); for (int n = 0; n < N; n++) { sizes[n] = Integer.parseInt(st.nextToken()); } Arrays.sort(sizes); int lt = 0; int rt = 0; long len; long ans = 1; while (lt < N) { while (rt < N - 1 && sizes[rt + 1] <= sizes[lt] + diff) rt++; len = rt - lt + 1; ans = (ans * len) % MOD; lt++; } out.println(ans); out.close(); } }
#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...