Submission #419942

# Submission time Handle Problem Language Result Execution time Memory
419942 2021-06-07T19:12:54 Z Haidara A Huge Tower (CEOI10_tower) C++17
100 / 100
138 ms 11204 KB
/*
ID: haidara
LANG: C++17
PROB: diamond
*/
#include<bits/stdc++.h>
#pragma GCC optimize("O1")
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define rep(i,x,n) for(int i=x;i<n;i++)
#define FOR(i,n) rep(i,0,n)
#define per(i,x,n) for(int i=x;i>n;i--)
#define ROF(i,x) for(int i=x;i>=0;i--)
#define v(i) vector< i >
#define p(i,j) pair< i , j >
#define pii pair<int,int>
#define m(i,j) map< i , j >
#define pq(i) priority_queue< i >
#define ff first
#define all(x) x.begin(),x.end()
#define ss second
#define pp push_back
using namespace std;
const int inf=1LL<<62LL;
const int mod=1e9+9;
const int maxn=200200;
signed main()
{
    //freopen("diamond.in","r",stdin);
    //freopen("diamond.out","w",stdout);
    fast;
    int n,d;
    cin>>n>>d;
    v(int)a(n);
    FOR(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    int r=0,sol=1;
    FOR(i,n)
    {
        while(r<n-1&&a[r+1]-a[i]<=d)
            r++;
        sol=(sol*(r-i+1))%mod;
    }
    cout<<sol;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1080 KB Output is correct
2 Correct 11 ms 1084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 4700 KB Output is correct
2 Correct 53 ms 4676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 11204 KB Output is correct
2 Correct 138 ms 10520 KB Output is correct