Submission #346564

# Submission time Handle Problem Language Result Execution time Memory
346564 2021-01-10T08:29:33 Z Ca7Ac1 A Huge Tower (CEOI10_tower) C++17
30 / 100
116 ms 10092 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;

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

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

    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());

    vector<ll> possible(N + 1, 1);

    ll j = 0;
    for (ll i = 0; i < N; i++)
    {
        while (j < N - 1 && blocks[j + 1] - blocks[i] <= D)
        {
            j++;
        }

        possible[i + 1] = possible[i] * ((j - i + 1) % MOD);
        possible[i + 1] %= MOD;
    }

    // ll sol = possible[0];
    // for (ll i = 1; i < N; i++)
    // {
    //     if (blocks[i - 1] - blocks[i] <= D)
    //     {
    //         if (possible[i] != 1)
    //         {
    //             sol += possible[i];
    //         }
    //     }
    //     else
    //     {
    //         sol *= possible[i];
    //     }

    //     sol %= MOD;
    // }

    cout << possible[N - 1];
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1132 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 4332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 116 ms 10092 KB Output isn't correct
2 Halted 0 ms 0 KB -