Submission #899700

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

using namespace std;

#define MOD 1000000009
#define MAXN 5000010

long long n,d;
long long niz[MAXN];
long long val[MAXN];

int main()
{
    cin>>n>>d;
    for (long long i=1;i<=n;i++) cin>>niz[i];
    sort(niz+1,niz+n+1);
    for (long long i=1;i<=n;i++)
    {
        long long br=0;
        for (long long j=i-1;j>=1;j--)
        {
            if (niz[i]-niz[j]<=d) br++;
            else break;
        }
        val[i]=br;
    }
    long long ans=1;
    for (long long i=1;i<=n;i++)
    {
        ans*=(val[i]+1);
        if (ans>=MOD) ans%=MOD;
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 6748 KB Output is correct
2 Correct 675 ms 6752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 357 ms 6748 KB Output is correct
2 Execution timed out 1014 ms 6992 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1067 ms 10856 KB Time limit exceeded
2 Halted 0 ms 0 KB -