Submission #365125

#TimeUsernameProblemLanguageResultExecution timeMemory
365125dg2004A Huge Tower (CEOI10_tower)Java
100 / 100
728 ms45948 KiB
import java.util.*; import java.io.*; public class tower { static int MOD = 1000000009; public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer token = new StringTokenizer(in.readLine()); int n = Integer.parseInt(token.nextToken()), d = Integer.parseInt(token.nextToken()); int[] ar = new int[n]; token = new StringTokenizer(in.readLine()); for (int a = 0; a < n; a++) ar[a] = Integer.parseInt(token.nextToken()); Arrays.sort(ar); int r = 0; int ans = 1; for (int l = 0; l < n; l++) { while (r < n - 1 && ar[r + 1] - ar[l] <= d) r++; int dist = r - l + 1; ans = (int)(((long)ans * dist) % 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...