Submission #528439

#TimeUsernameProblemLanguageResultExecution timeMemory
528439N1NT3NDOMagneti (COCI21_magneti)C++14
0 / 110
1089 ms436 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define sz(x) (int)x.size() #define fi first #define sd second #define all(x) x.begin(), x.end() //#pragma GCC target ("avx2") //#pragma GCC optimization ("O3") //#pragma GCC optimization ("unroll-loops") using namespace std; //using namespace __gnu_pbds; //typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; int n, L, R[55], ans; bool used[55]; void Rec(int skok) { if (skok == n + 1) { ans++; return; } for(int i = 1; i <= L; i++) { if (used[i]) continue; bool bad = 0; for(int j = 1; j <= L && !bad; j++) { if (used[j] && abs(j - i) < R[skok]) bad = 1; } if (!bad) { used[i] = 1; Rec(skok + 1); used[i] = 0; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> L; for(int i = 1; i <= n; i++) cin >> R[i]; sort(R + 1, R + n + 1); Rec(1); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...