Submission #867714

# Submission time Handle Problem Language Result Execution time Memory
867714 2023-10-29T10:03:29 Z Cookie A Huge Tower (CEOI10_tower) C++14
100 / 100
92 ms 8896 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("XMAS.INP");
ofstream fout("XMAS.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
//using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1e9 + 9;
const int mxn = 2e5 + 5, mxq = 2e5 + 5, sq = 500, mxv = 1e3 + 5;
const ll inf = 1e17 + 5;
//const int base= (1 << 18);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, d;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> d;
    vt<int>v(n);
    forr(i, 0, n)cin >> v[i];
    sort(v.begin(), v.end());
    ll ans = 1; 
    int l = 0;
    for(int i = 0; i < n; i++){
        while(v[i] - v[l] > d)l++;
        ans = (ans * 1LL * (i - l + 1)) % mod;
    }
    cout << ans;
    return(0);
}
# 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 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 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 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1112 KB Output is correct
2 Correct 7 ms 1368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3676 KB Output is correct
2 Correct 36 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 80 ms 8896 KB Output is correct
2 Correct 92 ms 8240 KB Output is correct