Submission #859836

# Submission time Handle Problem Language Result Execution time Memory
859836 2023-10-10T19:06:49 Z Lalic A Huge Tower (CEOI10_tower) C++17
100 / 100
117 ms 11236 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 3e5+10;
const int INF = 0x3f3f3f3f;
const ll LINF = 1e15;
const ll MOD = 1e9+9;

inline int mult(int a, int b){ return (1ll*a*b)%MOD; }

void solve(){
	int n, d; cin >> n >> d;

	vector<int> arr(n);
	for(int i=0;i<n;i++)
		cin >> arr[i];

	sort(all(arr));

	vector<int> opt(n);
	int low=0;
	for(int i=0;i<n;i++){
		while(low<n && arr[low]+d<arr[i])
			low++;

		opt[i]=i-low;
	}

	int ans=1;
	for(int i=0;i<n;i++)
		ans=mult(ans, opt[i]+1);

	cout << ans << "\n";
}

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

	// freopen("truth.in", "r", stdin);
    // freopen("truth.out", "w", stdout);

	int tt=1;
	// cin >> tt;
	while(tt--)
		solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 1116 KB Output is correct
2 Correct 7 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 4780 KB Output is correct
2 Correct 36 ms 4688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 11236 KB Output is correct
2 Correct 117 ms 10636 KB Output is correct