Submission #735261

#TimeUsernameProblemLanguageResultExecution timeMemory
735261dxfA Huge Tower (CEOI10_tower)Java
30 / 100
1040 ms51692 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 = new long[n]; former[0] = 1; Arrays.sort(sizes); for (int i = 1; i < n; i++) { long count = 1; int loc = i-1;; while (loc >= 0 && sizes[loc]+d >= sizes[i]) { count ++; loc--; } former[i] = ((long) former[i-1]) * count; } System.out.println(former[n-1]); } }
#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...