Submission #713052

#TimeUsernameProblemLanguageResultExecution timeMemory
713052NarkaA Huge Tower (CEOI10_tower)C++14
90 / 100
1066 ms16076 KiB
# 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)); ans[0] = 1; rep(i, 1, n-1){ int cnt = 1, j = i-1; while(j >= 0 && a[j] >= a[i] - d){ cnt++; j--; } ans[i] = (ans[i-1] * 1LL * cnt) % mod; } cout << ans[n-1] << endl; } signed main() { FAST solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...