Submission #391078

#TimeUsernameProblemLanguageResultExecution timeMemory
391078yu_limA Huge Tower (CEOI10_tower)Java
100 / 100
720 ms45380 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]; towers[0] = 1; int p = 0; // previous for (int i = 0; i < N; i++) { while (p < i) { if (blocks[p] + D < blocks[i]) p++; else break; } // # of blocks <= i that can't stack on i if (i > 0) towers[i] = (((i-p+1)) * towers[i - 1]) % M; } System.out.println(towers[N - 1] % M); } }
#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...