Submission #346543

# Submission time Handle Problem Language Result Execution time Memory
346543 2021-01-10T07:28:46 Z Ca7Ac1 A Huge Tower (CEOI10_tower) C++17
30 / 100
181 ms 88300 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

#define ll signed long long

using namespace std;

const ll MOD = (ll)10e9 + 9;

vector<ll> mem(10e6, -1);

bool cmpr(ll a, ll b)
{
    return a > b;
}

ll factorial(ll n)
{
    if (mem[n] == -1)
    {
        mem[n] = (n * factorial(n - 1)) % MOD;
    }

    return mem[n];
}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    //freopen("tower.in", "r", stdin);

    mem[0] = 1;
    mem[1] = 1;

    ll N;
    ll D;
    cin >> N >> D;

    vector<ll> blocks(N, 0);
    for (ll i = 0; i < N; i++)
    {
        cin >> blocks[i];
    }

    sort(blocks.begin(), blocks.end(), cmpr);

    vector<ll> possible(N, 1);
    ll sum = 1;
    ll j = 0;
    for (ll i = 0; i < N; i++)
    {
        j = max(j, i);
        sum = 1;
        while (j < N - 1 && blocks[i] - blocks[j + 1] <= D)
        {
            j++;
            sum *= j - i + 1;
            sum %= MOD;
        }

        possible[i] = sum;
    }

    ll sol = 1;
    for (ll mult : possible)
    {
        sol *= mult;
        sol %= MOD;
    }

    cout << sol;
}
# Verdict Execution time Memory Grader output
1 Correct 45 ms 78592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 78572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 78572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 42 ms 78572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 78700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 78700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 78828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 78572 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 43 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 78572 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 78620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 78700 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 78828 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 79340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 82668 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 181 ms 88300 KB Output isn't correct
2 Halted 0 ms 0 KB -