Submission #391760

#TimeUsernameProblemLanguageResultExecution timeMemory
391760huukhangA Huge Tower (CEOI10_tower)C++11
100 / 100
133 ms10456 KiB
// - Only when necessary :d // #pragma GCC optimize("Ofast") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fileopen(a, b) freopen(((string)a + ".inp").c_str(), "r", stdin); freopen(((string)b + ".out").c_str(), "w", stdout); #define ll long long #define int long long #define fi first #define se second #define pb push_back typedef pair<int, int> pii; typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const ll mod = 1e9 + 9; const ll inf = 1e9 + 7; const double eps = 1e-9; int n, d; int a[1000005]; int ans = 1; signed main() { #ifdef khangorz fileopen("input", "output"); #endif #ifndef khangorz // fileopen("LAH", "LAH"); #endif ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> d; for (int i = 1; i <= n; ++i) cin >> a[i]; sort(a + 1, a + n + 1); int p1 = 1, p2 = 1; for (; p1 <= n; ++p1) { while (p2 <= n && a[p2] - a[p1] <= d) ++p2; ans = (ans*(p2 - p1))%mod; } cout << ans; return 0; }
#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...