Submission #899727

# Submission time Handle Problem Language Result Execution time Memory
899727 2024-01-06T22:54:55 Z ivaziva A Huge Tower (CEOI10_tower) C++14
90 / 100
1000 ms 9920 KB
#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000009
#define MAXN 100010

long long n,d;
vector<long long> niz;

int main()
{
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>d;
    for (long long i=1;i<=n;i++)
    {
        long long x; cin>>x;
        niz.push_back(x);
    }
    sort(niz.begin(),niz.end());
    long long ans=1;
    for (long long i=0;i<n;i++)
    {
        long long j=i;
        while (j<n-1 and niz[j+1]-niz[i]<=d) j++;
        long long br=j-i+1;
        ans*=br; if (ans>=MOD) ans%=MOD;
    }
    cout<<ans<<endl;
}
# 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 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 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 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 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 992 KB Output is correct
2 Correct 553 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 250 ms 2532 KB Output is correct
2 Execution timed out 1037 ms 2516 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1020 ms 9920 KB Time limit exceeded
2 Halted 0 ms 0 KB -