Submission #135508

# Submission time Handle Problem Language Result Execution time Memory
135508 2019-07-24T07:16:04 Z 김세빈(#3248) A Huge Tower (CEOI10_tower) C++14
100 / 100
170 ms 11264 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 9;

ll A[1010101];
ll n, d, ans;

int main()
{
	ll i, j;
	
	scanf("%lld%lld", &n, &d);
	
	for(i=0; i<n; i++){
		scanf("%lld", A + i);
	}
	
	sort(A, A + n);
	
	ans = 1;
	
	for(i=0, j=0; i<n; i++){
		for(; A[j] + d < A[i]; j++);
		ans = ans * (i - j + 1) % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:16:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &d);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
tower.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld", A + i);
   ~~~~~^~~~~~~~~~~~~~~
# 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 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 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 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 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 348 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 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1272 KB Output is correct
2 Correct 14 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 4760 KB Output is correct
2 Correct 66 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 141 ms 11264 KB Output is correct
2 Correct 170 ms 10624 KB Output is correct