# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20439 | admin | 복불복 (OJUZ11_luck) | C++14 | 223 ms | 2024 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
scanf("%d", &n);
if(n > 10) return 0;
vector<int> a(n), b(n), p(n);
for(int i = 0; i < n; i++) scanf("%d", &a[i]);
for(int i = 0; i < n; i++) scanf("%d", &b[i]);
sort(a.begin(), a.end(), greater<int>());
sort(b.begin(), b.end(), greater<int>());
for(int i= 0; i < n; i++) p[i] = i;
int ans = 0;
do {
vector<int> sc(n);
for(int i = 0; i < n; i++) sc[i] = a[i] + b[p[i]];
bool good = true;
for(int i = 0; i < k; i++) {
int r = 0;
for(int j = 0; j < n; j++) {
if(sc[j] > sc[i]) r++;
}
if(r > k) good = false;
}
for(int i = 0; i < k; i++) {
for(int j = k; j < n; j++) {
if(sc[j] > sc[i]) good = false;
}
}
if(good) ans += 1;
}while(next_permutation(p.begin(), p.end()));
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |