Submission #713054

# Submission time Handle Problem Language Result Execution time Memory
713054 2023-03-21T02:11:21 Z Narka A Huge Tower (CEOI10_tower) C++14
90 / 100
1000 ms 9940 KB
# include<bits/stdc++.h>
using namespace std ;
# define F first
# define S second
# define int long long
# define in insert
# define pb push_back
# define pob pop_back
# define INF INT_MAX
# define INFL 1e18 + 10
# define mod 1000000009	
# define vi vector<int>
# define pii pair<int , int>
# define vvi vector< vector<int> >
# define vpi vector<pair<int, int>> 
# define all(v) v.begin() , v.end()
# define debug(x) cerr << '\n' << #x << " = " << x << '\n' ;
# define rep( i , s , e ) for( int i = s ; i <= e ; i++ )
# define repR( i , e , s ) for( int i = e ; i >= s ; i-- )
# define trav(a) for(auto& x : a)
# define bk back()
# define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
# define endl "\n"
# define vva2 vector<vector<array<int, 2>>>

void solve(){
	int n, d;
	cin >> n >> d;
	vi a(n), ans(n);
	for(auto& x : a) cin >> x;
	sort(all(a));
	int sol = 1;
	rep(i, 0, n-1){
		int cnt = 1, j = i+1;
		while(j < n && a[j] - a[i] <= d) cnt++, j++;
		sol = (sol * 1LL * cnt) % mod;
	}
	cout << sol << endl;

}

signed main() {	
//	FAST
	solve();
	return 0;
} 
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 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 0 ms 212 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 0 ms 212 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 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 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 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 1072 KB Output is correct
2 Correct 878 ms 1072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 465 ms 4208 KB Output is correct
2 Execution timed out 1080 ms 4180 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1066 ms 9940 KB Time limit exceeded
2 Halted 0 ms 0 KB -