# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
393910 | 2021-04-24T21:18:41 Z | tcmmichaelb139 | A Huge Tower (CEOI10_tower) | C++14 | 131 ms | 5164 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef string str; typedef pair<int, int> pi; typedef pair<ll, ll> pl; typedef pair<double, double> pd; typedef vector<int> vi; typedef vector<bool> vb; typedef vector<ll> vl; typedef vector<double> vd; typedef vector<string> vs; typedef vector<pi> vpi; typedef vector<pl> vpl; typedef vector<pd> vpd; #define vc vector #define pb push_back #define pf push_front #define rsz resize #define sz size #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define ub upper_bound #define lb lower_bound #define f first #define s second #define mp make_pair #define ln length #define IMX INT_MAX #define IMN INT_MIN void IO(string s = "") { ios_base::sync_with_stdio(0); cin.tie(0); if (s.length()) { freopen((s+".in").c_str(),"r",stdin); freopen((s+".out").c_str(),"w",stdout); } } int main() { IO(""); int n, d; cin >> n >> d; vi v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(all(v)); int r = 0, ans = 1; for (int l = 0; l < n; l++) { while (r < n-1 && v[r+1]-v[l] <= d) r++; int k = r-l+1; ans = (ans*1LL*k)%((int)1e9+9); } cout << ans << '\n'; } /* Stuff to look for * int overflow, array bounds * special cases (n=1) * do smth instead of nothing and stay organized * WRITE STUFF DOWN * DON'T GET STUCK ON ONE APPROACH */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 13 ms | 992 KB | Output is correct |
2 | Correct | 11 ms | 972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 62 ms | 3720 KB | Output is correct |
2 | Correct | 52 ms | 2192 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 110 ms | 5164 KB | Output is correct |
2 | Correct | 131 ms | 4428 KB | Output is correct |