Submission #857237

#TimeUsernameProblemLanguageResultExecution timeMemory
857237cloudyA Huge Tower (CEOI10_tower)C++14
100 / 100
99 ms11304 KiB
#include <bits/stdc++.h> #define fastIO \ ios_base::sync_with_stdio(false); \ cin.tie(nullptr) using namespace std; #pragma GCC optimize("O3,unroll-loops") #define ll long long #define pii pair<ll, ll> #define mp make_pair #define f first #define s second #define pb push_back const ll INF = 1000000000000000000; int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, 1, 0, -1}; string stepDir = "URDL"; template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template <typename A, typename B> ostream &operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } void dbg_out() { cerr << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } #ifdef DEBUG #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif #define MOD 1000000009 #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define tii tuple<ll, ll, ll> priority_queue<ll, vector<ll>, greater<ll>> minpq; int main() { fastIO; cout << fixed << setprecision(10); int n, d; cin >> n >> d; vector<ll> a(n); for (auto &x : a) cin >> x; sort(a.begin(), a.end()); ll ans = 1; int i = 0; for (int j = 0; j < n; ++j) { // push the right instead while (i < n - 1 && a[i + 1] - a[j] <= d) ++i; ans = (ans * (i - j + 1)) % 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...