oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • About
    • Terms of Use
    • Technical Specifications
    • Credits

tower Batch , stdin/stdout

Registered Users Only

Please login to utilize this feature.

Do note that this website only supports submissions in C++.

tower.html

Qi the Chuan Shen (船神) has decided to build a tower using boats! Each boat i has a width Wi. In order to prevent the tower from toppling, Qi has calculated that a boat of width A can only be placed directly on top of a boat of width B if A ≤ B+Q, where Q is Qi's constant. Help Qi compute the number of different towers he can build using each of the N boats exactly once!

Note: Two towers are different if the order of boats from bottom to top is different.

Input

On the first line are space-separated integers N (1 ≤ N ≤ 100,000) and Q (1 ≤ Q ≤ 1,000,000,000). The next N lines contain an integer each, the ith of which is the value Wi (1 ≤ Wi ≤ 1,000,000,000).

Output

On the first and only line output the number of possible towers, modulo 1,000,000,007.

Sample Input 1

4 1
1
2
3
3

Sample Output 1

12

Tags

Dynamic Programming

Subtasks and Limits

Subtask Score #TC Time Memory Scoring
1100201s32MBAverage
2011s32MBAverage

Judge Compile Command

g++-8 ans.cpp -o tower -Wall -Wshadow -static -O2 -lm -m64 -s -w -std=gnu++17 -fmax-errors=512

Accepted Submissions

subIDUserTimeMax Time

Past Submissions

subIDUserTimeScore
mrJudge 09.05.20
Copyright © 2020 mrJudge. All rights reserved.