Submission #365053

#TimeUsernameProblemLanguageResultExecution timeMemory
365053horsefeedapplesA Huge Tower (CEOI10_tower)C++11
20 / 100
297 ms11500 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MOD = 1e9+7; ll factorial(ll n){ if(n==0) return 1; return n*factorial(n-1); } int main() { ll n, d; cin>>n>>d; ll arr[n]; for(ll i=0; i<n; i++){ cin>>arr[i]; } sort(arr, arr+n); map<ll, ll> m; // value, number of values ll l = 0, r = 0; for(; l<n; l++){ if(arr[l]+d<arr[r]){ l = r; } while(arr[l]+d>=arr[r] && r<n){ m[l]=r-l+1; r++; } } ll ans = 1; for(auto u: m){ ans*=factorial(u.second); } cout<<(ans%MOD); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...