Submission #393966

# Submission time Handle Problem Language Result Execution time Memory
393966 2021-04-25T05:00:29 Z jadDebugs A Huge Tower (CEOI10_tower) C++14
100 / 100
309 ms 8976 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int mod = 1e9+9;

int main()
{
    int n, d; cin >> n >> d;

    vector<int> arr(n);
    vector<long long> dp(n);
    dp[0] = 1;

    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr.begin(), arr.end());
    
    for (int r = 1, l = 0; r < n; r++) {
        while (l < r && arr[l] + d < arr[r])
            l++;
        dp[r] = ((r-l+1) * dp[r-1]) % mod;
        dp[r] %= mod;
    }

    cout << dp[n-1];
}
# 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 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 208 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 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 844 KB Output is correct
2 Correct 26 ms 1356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 3148 KB Output is correct
2 Correct 132 ms 5528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 303 ms 7500 KB Output is correct
2 Correct 309 ms 8976 KB Output is correct