Submission #419944

# Submission time Handle Problem Language Result Execution time Memory
419944 2021-06-07T19:13:43 Z Haidara A Huge Tower (CEOI10_tower) C++17
100 / 100
437 ms 5068 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,inx=0;
    FOR(i,n)
    {
        FOR(j,1000)
        inx++;
        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 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 256 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 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 256 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 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 716 KB Output is correct
2 Correct 38 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 2252 KB Output is correct
2 Correct 172 ms 2252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 423 ms 5068 KB Output is correct
2 Correct 437 ms 5068 KB Output is correct