Submission #573484

# Submission time Handle Problem Language Result Execution time Memory
573484 2022-06-06T17:33:11 Z lam A Huge Tower (CEOI10_tower) C++17
100 / 100
122 ms 14028 KB
#include <bits/stdc++.h>
#define taskname "truth"
#define int long long
#define maxn 110
using namespace std;
int n,d;
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
//    freopen(taskname".in","r",stdin);
//    freopen(taskname".out","w",stdout);
    cin>>n>>d;
    vector <int> a;
    for (int i=1; i<=n; i++)
    {
        int x; cin>>x;
        a.push_back(x);
    }
    sort(a.begin(),a.end());
    int r=0;
    int ans=1ll;
    int mod=1e9+9;
    for (int l=0; l<n; l++)
    {
        while (r<n-1&&a[r+1]-a[l]<=d) r++;
        int temp=r-l+1;
        ans=(ans*temp)%mod;
    }
    cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1428 KB Output is correct
2 Correct 10 ms 1404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 53 ms 4880 KB Output is correct
2 Correct 48 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 14028 KB Output is correct
2 Correct 122 ms 13452 KB Output is correct