# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
347406 | 2021-01-12T23:27:07 Z | danielsuh | A Huge Tower (CEOI10_tower) | C++17 | 140 ms | 16124 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define mpa make_pair #define pb push_back #define ins insert #define f first #define s second #define all(x) x.begin(), x.end() #define nl "\n" #define int ll const int inf = numeric_limits<int>::max(); void fileIO(string filename) { freopen((filename + ".in").c_str(), "r", stdin); freopen((filename + ".out").c_str(), "w", stdout); } const ll MOD = 1e9 + 9; void solve() { int n, d; cin >> n >> d; vector<int> a(n, 0); for(int i = 0; i < n; i++) { cin >> a[i]; } sort(all(a), greater<>()); vector<int> mult(n, 1); int r = 0; for(int l = 0; l < n; l++) { while(r < n && a[l] - a[r] <= d) { r++; } mult[l] = r - l; } int ans = 1; for(int i = n - 1; i >= 0; i--) { ans *= mult[i] % MOD; ans %= MOD; } cout << ans % MOD; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); //fileIO(""); int tc = 1; //cin >> tc; for(int i = 1; i <= tc; i++) { solve(); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 1644 KB | Output is correct |
2 | Correct | 11 ms | 1644 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 63 ms | 6764 KB | Output is correct |
2 | Correct | 54 ms | 6764 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 16124 KB | Output is correct |
2 | Correct | 140 ms | 15468 KB | Output is correct |