Skip to content

Instantly share code, notes, and snippets.

@hiroshi-cl
Created June 25, 2013 07:54
Show Gist options
  • Save hiroshi-cl/5856744 to your computer and use it in GitHub Desktop.
Save hiroshi-cl/5856744 to your computer and use it in GitHub Desktop.
2011年 冬合宿4日目 Problem E : Rabbit Game Playing [Licence: NYSL Version 0.9982]
import static java.util.Arrays.*;
public class Main {
public static void main(String... args) {
new Main().run();
}
static final long MOD = 1000 * 1000 * 1000 + 7;
public void run() {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int T = sc.nextInt();
int[] D = new int[N];
for(int i = 0; i < N; i++)
D[i] = sc.nextInt();
sort(D);
long ans = 1L;
for(int i = 0, j = 0; i < N; i++) {
while(j < N && D[j] <= D[i] + T)
j++;
ans *= j - i;
ans %= MOD;
}
System.out.println(ans);
}
}
class Scanner {
final java.util.Scanner sc;
public Scanner(java.io.InputStream is) {
this.sc = new java.util.Scanner(is);
}
public int nextInt() {
return Integer.parseInt(sc.next());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment