Submission #345374

# Submission time Handle Problem Language Result Execution time Memory
345374 2021-01-07T08:05:22 Z leu_naut A Huge Tower (CEOI10_tower) C++11
90 / 100
103 ms 5764 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn=2e5+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 512 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 512 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 268 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 512 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 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 1260 KB Output is correct
2 Correct 31 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 88 ms 5740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 103 ms 5764 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -