제출 #654071

#제출 시각아이디문제언어결과실행 시간메모리
654071atharvdA Huge Tower (CEOI10_tower)C++14
90 / 100
269 ms5128 KiB
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<cmath> #include<fstream> #define for_n(i,a,n) for (int i=a;i<n;i++) #define pb push_back #define mp(i, j) make_pair(i, j) #define MOD 1000000009 typedef long long ll; using namespace std; int main(){ int n, d; cin >> n >> d; int arr[n]; for(int i = 0; i < n; i++){ cin >> arr[i]; } sort(arr, arr + n); int un = 0; int deux = 0; int b[n]; int count = 1; b[0] = count; while(un < n - 1 || deux < n - 1){ if(arr[deux] - arr[un] <= d){ if(deux != n - 1){ b[deux] = deux - un + 1; deux++; count++; } else{ b[deux] = deux - un + 1; break; } } else{ while(arr[deux] - arr[un] > d){ un++; count--; } } //cout << un << " " << deux << endl; } ll ans = 1; for(auto a: b){ ans *= ll(a); ans %= MOD; } cout << ans << endl; }
#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...