Submission #346573

# Submission time Handle Problem Language Result Execution time Memory
346573 2021-01-10T08:44:40 Z Ca7Ac1 A Huge Tower (CEOI10_tower) C++17
0 / 100
123 ms 14844 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;

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(), greater<ll>());

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

        place[i] = (j - i) % MOD;
    }

    vector<ll> count(N, 1);
    for (ll i = N - 2; i >= 0; i--)
    {
        count[i] = count[i + 1] * place[i];
        count[i] %= MOD;
    }

    cout << count[0] - 1;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 364 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 376 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 0 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 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 492 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 620 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 1516 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 58 ms 6272 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 123 ms 14844 KB Output isn't correct
2 Halted 0 ms 0 KB -