# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20487 | 볼빨간민돌이 (#35) | 복불복 (OJUZ11_luck) | C++11 | 3 ms | 1120 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 <cstdio>
#include <algorithm>
#include <cstdlib>
using namespace std;
int n, k, a[101], b[101];
const int mod = 1e9+7;
void sub1(){
int t[9];
sort(a+1, a+n+1);
reverse(a+1, a+n+1);
sort(b+1, b+n+1);
int ans=0;
do{
for(int i=1; i<=n; i++)
t[i]=a[i]+b[i];
bool flag=true;
for(int i=1; i<=k; i++){
int bigCnt=0;
for(int j=1; j<=n; j++)
if(t[i] < t[j]) bigCnt++;
if(bigCnt+1 > k) flag=false;
}
for(int i=k+1; i<=n; i++)
for(int j=1; j<=k; j++)
if(t[i] > t[j]) flag=false;
if(flag) ans++;
}while(next_permutation(b+1, b+n+1));
printf("%d", ans);
exit(0);
}
void sub2(){
sort(a+1, a+1+n);
reverse(a+1, a+1+n);
int ans=0;
for(int i=1; i<=n; i++){
int x = a[1]+b[i];
int val=1;
for(int j=2; j<=n; j++){
int cnt=0;
for(int k=1; k<=n; k++){
if(k==i) continue;
if(a[j]+b[k] <= x) cnt++;
}
val=val*1ll*max(cnt-j+2, 0)%mod;
}
ans=(ans+val)%mod;
}
printf("%d", ans);
exit(0);
}
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]);
if(n<=8) sub1();
if(k==1) sub2();
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... |