Submission #883314

#TimeUsernameProblemLanguageResultExecution timeMemory
883314phoenix0423Skyscraper (JOI16_skyscraper)C++17
5 / 100
2047 ms464 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define fastio ios::sync_with_stdio(false), cin.tie(0) // #pragma GCC optimize("Ofast") #define FOR(i, a, b) for(int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define REP1(i, n) FOR(i, 0, n + 1) #define SZ(x) (int)(x).size() #define pb push_back #define pf push_front #define eb emplace_back #define f first #define s second #define lowbit(x) x&-x #define ckmin(a, b) a = min(a, b) #define ckmax(a, b) a = max(a, b) #define int long long const int INF = 1e18; const int maxn = 1000 + 5; const int N = 1e9 + 7; ll dp[105][105][2005][3]; signed main(void){ fastio; int n, l; cin>>n>>l; vector<int> a(n); for(int i = 0; i < n; i++) cin>>a[i]; sort(a.begin(), a.end()); vector<int> p(n); for(int i = 0; i < n; i++) p[i] = i; int cnt = 0; int ttl = 0; do{ ttl++; int dif = 0; for(int i = 0; i < n - 1; i++) dif += abs(a[p[i + 1]] - a[p[i]]); if(dif <= l) cnt++; }while(next_permutation(p.begin(), p.end())); cout<<cnt<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...