# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1056847 | tkvinhtruongquang | A Huge Tower (CEOI10_tower) | C++14 | 74 ms | 8260 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define clz __builtin_clz
#define popcount __builtin_popcount
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
#define loop(i, j, n, k) for(int i = j; i <= n; i += k)
#define fast ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
template <typename T>
inline void print(T x) { cerr << x << endl; }
template <typename T>
inline void print(vector <T> x) { cerr << '['; loop(i, 0, sz(x) - 2, 1) cerr << x[i] << ", "; cerr << x.back() << ']' << endl; }
template <typename T>
inline bool maximize(T &a, const T &b) { return a < b ? (a = b) : 0; }
template <typename T>
inline bool minimize(T &a, const T &b) { return a > b ? (a = b) : 0; }
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
#define debug(x) cerr << #x << " = "; print(x)
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
freopen("error.txt", "w", stderr);
}
const int mod = 1e9 + 9;
namespace sub1 {
int n;
int k;
vi arr;
vi per;
void input(int _k, vi &_arr) {
arr = _arr;
k = _k;
n = sz(arr);
loop(i, 0, n - 1, 1) per.pb(i);
}
void solve() {
int ans = 0;
do {
bool check = true;
loop(i, 1, n - 1, 1) {
if(arr[per[i]] > arr[per[i - 1]] + k) {
check = false;
break;
}
}
ans += check;
} while(next_permutation(all(per)));
cout << ans;
}
}
int main() {
// setIO("task");
fast;
int n, k; cin >> n >> k;
vi arr(n); for(auto &i : arr) cin >> i;
sort(all(arr));
int r = 0, sol = 1;
loop(l, 0, n - 1, 1) {
while(r < n - 1 && arr[r + 1] <= arr[l] + k) ++ r;
int dist = r - l + 1;
sol = (1LL * sol * dist) % mod;
}
cout << sol;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |