Submission #350132

#TimeUsernameProblemLanguageResultExecution timeMemory
350132CelloboyA Huge Tower (CEOI10_tower)Java
25 / 100
731 ms51780 KiB
import java.io.*; import java.util.*; public class tower { static long MOD = (long)1e9+7; public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int N = Integer.parseInt(st.nextToken()), K = Integer.parseInt(st.nextToken()); int arr[] = new int[N]; st = new StringTokenizer(br.readLine()); for(int i = 0; i < N; i++) { arr[i] = Integer.parseInt(st.nextToken()); } int fact[] = new int[N+1]; fact[0]=1; for(int i = 1; i <= N; i++) { fact[i] = mult(fact[i-1],i); } Arrays.sort(arr); int right = 0; int ans = 1; for(int left = 0; left < N; ++left) { int s = 0; while(right< N && arr[left]+ K >= arr[right]) {++right; ++s;} if(s==0) continue; ans = mult(fact[right-left],ans); //System.out.println(right+" " + left); } System.out.println(ans); }/* private static int add(int a, int b) { // TODO Auto-generated method stub return (int) (a+b>=MOD ? a+b-MOD:a+b); }*/ private static int mult(int a, int b) { // TODO Auto-generated method stub return (int)((long)(a*b)%MOD); } }
#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...