Submission #498635

# Submission time Handle Problem Language Result Execution time Memory
498635 2021-12-26T01:15:39 Z aadit_ambadkar A Huge Tower (CEOI10_tower) C++11
100 / 100
118 ms 13148 KB
/*
    This code belongs to Aadit Ambadkar
    Date: 2021-12-25 16:34:50
    Problem: tower
*/
#include <bits/stdc++.h>
using namespace::std;

typedef long long ll;
#define F0R(i, n) for (int i = 0; i < n; i++)
#define R0F(i, n) for (int i = n-1; i >= 0; i--)
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define fastio ios::sync_with_stdio(0); cin.tie(0)
#define MOD 1000000009
#define FF first
#define SS second

int main() {
    fastio;
    int n, d; cin >> n >> d;
    vector<int> v;
    F0R(i, n) {
        int x; cin >> x;
        v.pb(x);
    }
    sort(v.begin(), v.end());
    vector<ll> dp(n, 0);
    dp[0]=1;
    int p = 0;
    FOR(i, 1, n) {
        while (v[i]-v[p]>d) p++;
        dp[i]=dp[i-1]*(i-p+1);
        dp[i]%=MOD;
    }
    cout << dp[n-1] << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 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 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 976 KB Output is correct
2 Correct 10 ms 1456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 46 ms 3320 KB Output is correct
2 Correct 45 ms 5804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 7624 KB Output is correct
2 Correct 118 ms 13148 KB Output is correct