Submission #735263

#TimeUsernameProblemLanguageResultExecution timeMemory
735263dxfA Huge Tower (CEOI10_tower)Java
100 / 100
674 ms50640 KiB
// Source: https://usaco.guide/general/io import java.io.*; import java.util.*; public class tower { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(r.readLine()); int n = Integer.parseInt(st.nextToken()); int d = Integer.parseInt(st.nextToken()); int[] sizes = new int[n]; st = new StringTokenizer(r.readLine()); for (int i = 0; i < n; i++) { sizes[i] = Integer.parseInt(st.nextToken()); } long former = 1; Arrays.sort(sizes); int loc = 0; for (int i = 0; i < n; i++) { while (loc < n-1 && sizes[loc+1]-sizes[i] <= d) { loc ++; } int dist = loc-i+1; former = (((long) former) * dist) % 1000000009; } System.out.println(former); } }
#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...