Submission #160757

# Submission time Handle Problem Language Result Execution time Memory
160757 2019-10-29T20:47:47 Z luciocf A Huge Tower (CEOI10_tower) C++14
100 / 100
170 ms 8988 KB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 1e6+10;
const int mod = 1e9+9;

int a[maxn];

int main(void)
{
	int n, d;
	scanf("%d %d", &n, &d);

	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);

	sort(a+1, a+n+1);

	int ans = 1, ptr = 1;

	for (int i = 1; i <= n; i++)
	{
		while (ptr < i && a[ptr]+d < a[i])
			ptr++;

		ans = (1ll*ans*(i-ptr+1))%mod;
	}

	printf("%d\n", ans);
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &d);
  ~~~~~^~~~~~~~~~~~~~~~~
tower.cpp:16:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &a[i]);
   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1060 KB Output is correct
2 Correct 14 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 3808 KB Output is correct
2 Correct 78 ms 3832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 138 ms 8988 KB Output is correct
2 Correct 170 ms 8280 KB Output is correct