Submission #419946

# Submission time Handle Problem Language Result Execution time Memory
419946 2021-06-07T19:14:29 Z Haidara A Huge Tower (CEOI10_tower) C++17
85 / 100
1000 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,100000)
        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 1 ms 304 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 2 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 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 108 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 492 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1098 ms 588 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1083 ms 2252 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1097 ms 5068 KB Time limit exceeded
2 Halted 0 ms 0 KB -