Submission #856864

# Submission time Handle Problem Language Result Execution time Memory
856864 2023-10-04T17:57:12 Z Euclid73 A Huge Tower (CEOI10_tower) C++17
100 / 100
204 ms 10504 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const ll MOD=1e9+9;

int main()
{
    ll n, d;
    cin >> n >> d;
    ll a[n];
    for (int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    ll r=0, ans=1;
    for (ll i=0; i<n; i++)
    {
        while (r+1<n && a[r+1]<=a[i]+d)
        {
            r++;
        }
        ans=ans*(r-i+1);
        ans=ans%MOD;
    }
    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 816 KB Output is correct
2 Correct 24 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 2140 KB Output is correct
2 Correct 84 ms 4804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 5256 KB Output is correct
2 Correct 204 ms 10504 KB Output is correct