# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
596662 | 2022-07-15T00:19:15 Z | Merakulus | A Huge Tower (CEOI10_tower) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <algorithm> #include <vector> using namespace std; #define mod 1e9 int main(){ int n = 0; int d = 0; int ans = 1; cin >> n >> d; vector<int> size(n); for(int i = 0; i < n; i++){ cin >> size[i]; } sort(size.begin(), size.end()); int r = 0; for(int i = 0; i < n; i++){ while(r < n && size[r] - size[i] <= d){ r += 1; } int tSize = r - i; ans *= tSize % mod; } cout << ans << endl; return 0; }