Submission #952693

# Submission time Handle Problem Language Result Execution time Memory
952693 2024-03-24T14:46:38 Z doducanh A Huge Tower (CEOI10_tower) C++14
100 / 100
203 ms 11984 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod=1e9+9;
int a[1000005];
int n,k;
main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    int r=0;
    int sol=1;
    for(int i=1;i<=n;i++){
        while(r<n&&a[r+1]-a[i]<=k)r++;
        r=max(r,i);
        int dist=(r-i+1);
        sol=(1ll*sol*dist)%mod;
    }
    cout<<sol;
    return 0;
}

Compilation message

tower.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 1 ms 496 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 1 ms 344 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 1 ms 356 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 1 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 1 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2648 KB Output is correct
2 Correct 17 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 2652 KB Output is correct
2 Correct 85 ms 4940 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 199 ms 6740 KB Output is correct
2 Correct 203 ms 11984 KB Output is correct