Submission #535812

#TimeUsernameProblemLanguageResultExecution timeMemory
535812makanhuliaA Huge Tower (CEOI10_tower)C++17
20 / 100
1095 ms13300 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll mod = 1e9+9; vector<ll>v; vector<ll>tmp; vector<bool>mark; ll n, d; ll f(int idx, ll last){ if(idx == n){ return 1; } ll ret = 0; for(int i = 0; i < n; i++){ if(!mark[i] && (v[i] <= last + d)){ //cout << "can stack " << v[i] << " on top of " << last << endl; mark[i] = true; tmp.push_back(v[i]); ret += f(idx + 1, v[i]); mark[i] = false; tmp.pop_back(); } } return (ret % mod); } int main(){ cin >> n >> d; for(int i = 0; i < n; i++){ ll x; cin >> x; v.push_back(x); mark.push_back(0); } cout << (f(0, 1e9) % mod) << endl; 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...