제출 #755818

#제출 시각아이디문제언어결과실행 시간메모리
755818vjudge1A Huge Tower (CEOI10_tower)C++17
20 / 100
1080 ms6484 KiB
#include <bits/stdc++.h> using namespace std; #define vi vector<int> #define vl vector<long long> #define vii vector<pair<int,int>> #define vll vector<pair<long long,long long>> #define pb push_back #define ll long long #define ld long double #define nl '\n' #define boost ios::sync_with_stdio(false) #define mp make_pair #define se second #define fi first #define fore(i, y) for(ll i = 0; i < y; i++) #define forr(i,x,y) for(int i = x;i<=y;i++) #define forn(i,y,x) for(ll i = y; i >= x; i--) #define all(v) v.begin(),v.end() #define sz(v) v.size() #define clr(v,k) memset(v,k,sizeof(v)) #define rall(v) v.rbegin() , v.rend() #define pii pair<int,int> #define pll pair<ll , ll> const ll MOD = 1e9 + 9; const ll INF = 1e18 + 1; ll gcd(ll a , ll b) {return b ? gcd(b , a % b) : a ;} // greatest common divisor (PGCD) ll lcm(ll a , ll b) {return a * (b / gcd(a , b));} // least common multiple (PPCM) // HERE IS THE SOLUTION vi s; int n , d; vector<bool> vis; int solve(int i) { bool acc = 0; int ans = 0; forr(j , 0, n-1) { if(j==i)continue; if(s[j] <= d + s[i]&&!vis[j]) { acc = 1; vis[j] = 1; (ans+=solve(j))%=MOD; vis[j] = 0; } } if(!acc) { fore(j , n) { if(!vis[j])return 0; } return 1; } else { return ans; } } int main() { cin.tie(0); cout.tie(0); boost; cin>>n>>d; s.assign(n , 0); vis.assign(n , 0); fore(i , n) { cin>>s[i]; } sort(rall(s)); int res = 0; fore(i , n) { vis.clear(); vis.assign(n , 0); vis[i] = 1; (res+=solve(i))%=MOD; } cout<<res<<nl; }
#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...