# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20479 | 대신귀여운알파카를드리겠습니다 (#35) | 복불복 (OJUZ11_luck) | C++11 | 0 ms | 2020 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, a[105], b[105], per[105];
long long ans;
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) {
scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++) {
scanf("%d",&b[i]);
}
sort(a+1, a+1+n);
sort(b+1, b+1+n);
reverse(a+1, a+1+n);
if(n <= 8 && k > 1) {
for(int i=1;i<=n;i++) per[i] = i;
do {
int flag = 1;
for(int i=1;i<=k;i++) {
for(int j=k+1;j<=n;j++) {
if(a[i]+b[per[i]] < a[j]+b[per[j]]) {
flag = 0; break;
}
}
if(!flag) break;
}
ans += flag;
} while(next_permutation(per+1, per+1+n));
}
else if(k == 1) {
for(int i=1;i<=n;i++) {
long long cur = 1;
for(int j=2;j<=n;j++) {
long long x;
for(x=1;x<=n;x++) {
if(a[j] + b[x] > a[1] + b[i]) break;
}
cur *= max(x-j+1, 0ll);
}
ans += cur;
}
}
printf("%lld\n",ans);
}
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... |