Submission #634719

# Submission time Handle Problem Language Result Execution time Memory
634719 2022-08-24T18:06:54 Z iulia13 A Huge Tower (CEOI10_tower) C++14
100 / 100
260 ms 8776 KB
#include <bits/stdc++.h>

using namespace std;
#define ll long long
const int MOD = 1e9 + 9;
const int N = 1e6 + 5;
int v[N];
ll ans = 1;
int main()
{
    int n, d;
    cin >> n >> d;
    for (int i = 1; i <= n; i++)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    int j = 1;
    ans = 1;
    for (int i = 2; i <= n; i++)
    {
        while (j < i && v[j] + d < v[i])
            j++;
        ans = ans * (1ll *(i - j + 1));
        ans %= MOD;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 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 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 972 KB Output is correct
2 Correct 24 ms 932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 3708 KB Output is correct
2 Correct 129 ms 3608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 260 ms 8776 KB Output is correct
2 Correct 258 ms 8176 KB Output is correct