Submission #436007

# Submission time Handle Problem Language Result Execution time Memory
436007 2021-06-24T05:00:24 Z ak2006 A Huge Tower (CEOI10_tower) C++14
100 / 100
158 ms 8732 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
const ll mod = 1e9 + 9,inf = 1e18;
#define pb push_back
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
void setIO()
{
    fast;
}
int main()
{
    setIO();
    int n,d;
    cin>>n>>d;
    vi a(n);
    for (int i = 0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    ll ans = 1;
    int pos = 0;
    for (int i = 0;i<n;i++){
        while (a[pos] < a[i] - d)pos++;
        ans = (ans * (1ll * (i - pos + 1)))%mod;
        if (ans < 0)ans += mod;
    }
    cout<<ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 972 KB Output is correct
2 Correct 11 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 3716 KB Output is correct
2 Correct 59 ms 3720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8732 KB Output is correct
2 Correct 158 ms 8124 KB Output is correct