Submission #480394

# Submission time Handle Problem Language Result Execution time Memory
480394 2021-10-16T05:38:07 Z nehasane A Huge Tower (CEOI10_tower) C++14
15 / 100
306 ms 2704 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000009;
long long factorial(int s){
    long long ans = 1;
    for (int i = s; i >= 1; i--)
        ans *= i;
    return ans % mod;
}
int main()
{
    int n, d;
    cin >> n >> d;
    vector <int> blocks(n);
    for (int i = 0; i < n; i++)
        cin >> blocks[i];
    sort(begin(blocks), end(blocks));
    long long ans = 1;
    int l = 0, r = 0;
    while (r < n){
        if (blocks[l] + d < blocks[r]){
            ans = (ans * factorial(r-l)) % mod;
            if (blocks[r] + d >= blocks[r+1])
                l = r-1;
            else
                l = r;
        }
        r++;
    }
    cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't 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 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 1268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 306 ms 2704 KB Output isn't correct
2 Halted 0 ms 0 KB -