# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
703110 |
2023-02-26T06:54:02 Z |
ef10 |
A Huge Tower (CEOI10_tower) |
C++17 |
|
1000 ms |
11148 KB |
// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
long long N, D;
long long factor(long long n, long long m) {
long long ret = 1;
for (long long i = m; i <= n; i++) {
ret *= i;
ret %= 1000000009;
}
return ret;
}
long long solve(const vector<long long>& a, long long start, long long end) {
if (start == end) return 1;
long long ret = factor(end - start + 1, 1);
//cout << "solve init: " << start << ", " << end << ", " << ret << endl;
long long lo = start;
long long hi = start + 1;
while (hi <= end) {
if (a[hi] - a[lo] > D) {
ret -= (end - hi + 1) * factor(end - start, 1);
//cout << "minus: " << end << ", " << hi << ", " << start << endl;
lo++;
while (a[hi] - a[lo] > D) {
ret -= (end - hi + 1) * factor(end - start, 1);
//cout << "minus: " << end << ", " << hi << ", " << start << endl;
lo++;
}
}
hi++;
}
//cout << "result: " << ret << endl;
return ret;
}
int main() {
cin >> N >> D;
vector<long long> a(N);
for (long long i = 0; i < N; ++i) {
cin >> a[i];
}
sort(a.begin(), a.end());
long long start = 0;
long long end = 0;
long long total = 1;
while (end < N -1) {
if (a[end+1] - a[end] > D) {
total *= solve(a, start, end);
total %= 1000000009;
end++;
start = end;
continue;
}
end++;
}
total *= solve(a, start, end);
total %= 1000000009;
cout << total << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
16 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1079 ms |
1080 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1072 ms |
4672 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1073 ms |
11148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |