Submission #391083

#TimeUsernameProblemLanguageResultExecution timeMemory
391083yu_limA Huge Tower (CEOI10_tower)Java
100 / 100
720 ms45440 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[] blocks = new int[N]; str = new StringTokenizer(br.readLine()); for (int i = 0; i < N; i++) blocks[i] = Integer.parseInt(str.nextToken()); br.close(); Arrays.sort(blocks); long[] towers = new long[N]; // # ways to make a tower with i blocks towers[0] = 1; for (int i = 1, p = 0; i < N; i++) { while (p < i && blocks[p] + D < blocks[i]) p++; towers[i] = ((i - p + 1) * towers[i - 1]) % M; } System.out.println(towers[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...