Submission #345375

# Submission time Handle Problem Language Result Execution time Memory
345375 2021-01-07T08:06:17 Z leu_naut A Huge Tower (CEOI10_tower) C++11
100 / 100
451 ms 10732 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn=1e6+1,MOD=1e9+9;
ll h[maxn];
int main()
{
   ll n,d;
   cin>>n>>d;
   ll ans=1;
   for (ll i=1;i<=n;i++) cin>>h[i];
   sort(h+1,h+1+n);
   for (ll i=1;i<=n;i++)
   {
       ll pos=upper_bound(h+1,h+1+n,h[i]-d-1)-h;
//cerr<<pos<<" ";
       if (h[pos]>=h[i]-d) pos=i-pos+1;
       else pos=1;
       //cerr<<pos<<endl;
       //pos++;
       ans*=pos;
       ans%=MOD;
   }
   cout<<ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 748 KB Output is correct
2 Correct 27 ms 748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 142 ms 2616 KB Output is correct
2 Correct 154 ms 4784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 344 ms 9128 KB Output is correct
2 Correct 451 ms 10732 KB Output is correct