Submission #989972

# Submission time Handle Problem Language Result Execution time Memory
989972 2024-05-29T09:28:38 Z IdanRosen A Huge Tower (CEOI10_tower) C++
100 / 100
108 ms 10688 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define MOD ((ll) 1e9 + 9)

int main() {
    ios_base::sync_with_stdio(false);
    cout.tie(nullptr);
    cin.tie(nullptr);

    ll n, d;
    cin >> n >> d;

    vector<ll> arr(n);
    for (auto &ref: arr) cin >> ref;

    std::sort(arr.begin(), arr.end());

    ll ans = 1;
    for (int i = 1; i < n; i++) {
        ll curr_width = arr[i];

        ll start = 0;
        ll end = i;
        while (start < end) {
            ll mid = start + (end - start) / 2;
            if (arr[mid] + d < curr_width)
                start = mid + 1;
            else
                end = mid;
        }

        ans = ans * ((1 + i - start) % MOD);
        ans %= MOD;
    }

    cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 604 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 2396 KB Output is correct
2 Correct 36 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 77 ms 5208 KB Output is correct
2 Correct 108 ms 10688 KB Output is correct