Submission #932895

#TimeUsernameProblemLanguageResultExecution timeMemory
932895KavelmydexA Huge Tower (CEOI10_tower)C++17
10 / 100
1070 ms604 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int,int> #define vi vector<int> #define rep(i,x,n) for(int i=x; i<n; ++i) #define For(i,n) rep(i,0,n) #define pb push_back // #define f first #define s second #define endl "\n" #define sp ' ' #define sz size() #define all(x) (x).begin(),(x).end() const int N = 100, OO = 1e18, mod = 1e9+9, mx = 1e6+10; void tr(int a, int b){cout << a << sp << b << endl;} void cmx(int &a, int b){a = max(a,b);} void cmn(int &a, int b){a = min(a,b);} int n,k; int a[N], vis[N], ans; vi c; void calc(int j){ if(j >= n){ bool ok = 1; for(int i=1; i<n; ++i) ok &= (c[i]-c[i-1] <= k); if(ok) ans++; return; } For(i,n) if(!vis[i]){ vis[i] = 1; c.pb(a[i]); calc(j+1); c.pop_back(); vis[i] = 0; } } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; For(i,n) cin >> a[i]; calc(0); cout << ans%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...