Submission #391084

#TimeUsernameProblemLanguageResultExecution timeMemory
391084yu_limA Huge Tower (CEOI10_tower)Java
100 / 100
718 ms45420 KiB
import java.util.*; import java.io.*; public class tower { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer str = new StringTokenizer(br.readLine()); int N = Integer.parseInt(str.nextToken()); int D = Integer.parseInt(str.nextToken()); int M = 1_000_000_009; int[] block = new int[N]; str = new StringTokenizer(br.readLine()); for (int i = 0; i < N; i++) block[i] = Integer.parseInt(str.nextToken()); br.close(); Arrays.sort(block); long ways = 1; // # ways to make a tower with i blocks for (int i = 1, p = 0; i < N; i++) { while (p < i && block[p] + D < block[i]) p++; ways = ((i - p + 1) * ways) % M; } System.out.println(ways); } }
#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...