Submission #321270

# Submission time Handle Problem Language Result Execution time Memory
321270 2020-11-11T19:38:34 Z xyzyzl A Huge Tower (CEOI10_tower) C++14
95 / 100
173 ms 7652 KB
#include <bits/stdc++.h>

#define MOD 1000000009
#define ll long long
using namespace std;

int n, d, a[400005];
ll w[400005], tot[400005];
int main()
{
	cin >> n >> d; for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a+n);
	tot[0] = 1;
	int lo=0;
	for(int i = 0; i < n; i++)
	{
		while(a[lo]+d < a[i]) lo++;
		w[i] = (i-lo)+1;
	}
	// for(int i = 0; i < n; i++) cerr << w[i] << endl;
	for(int i = 1; i < n; i++)
	{
		tot[i] = (tot[i-1]*w[i]) % MOD;
	}
	cout << tot[n-1] << endl;
}
# 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 0 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 0 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 360 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 2 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 27 ms 1508 KB Output is correct
2 Correct 30 ms 1472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 132 ms 6628 KB Output is correct
2 Correct 132 ms 7652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 173 ms 6884 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -