Submission #555948

# Submission time Handle Problem Language Result Execution time Memory
555948 2022-05-01T21:35:09 Z blue A Huge Tower (CEOI10_tower) C++17
100 / 100
111 ms 8736 KB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

using vi = vector<int>;
using ll = long long;


const ll mod = 1'000'000'009LL;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int N, D;
	cin >> N >> D;

	vi H(N);
	for(int i = 0; i < N; i++)
		cin >> H[i];
	sort(H.begin(), H.end());

	ll res = 1;

	int j = 0;

	int l = 0;
	for(int r = 0; r < N; r++)
	{
		while(H[l] + D < H[r])
			l++;

		res = (res * (r-l+1))%mod;
	}

	cout << res << '\n';
}

Compilation message

tower.cpp: In function 'int main()':
tower.cpp:27:6: warning: unused variable 'j' [-Wunused-variable]
   27 |  int j = 0;
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# 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 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 892 KB Output is correct
2 Correct 14 ms 920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 3740 KB Output is correct
2 Correct 61 ms 3708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 8736 KB Output is correct
2 Correct 111 ms 8096 KB Output is correct