QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841911#9967. Imbalanced Teamsucup-team3555#RE 5ms19048kbC++201.1kb2025-01-04 08:48:182025-01-04 08:48:19

Judging History

你现在查看的是最新测评结果

  • [2025-01-04 08:48:19]
  • 评测
  • 测评结果:RE
  • 用时:5ms
  • 内存:19048kb
  • [2025-01-04 08:48:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N=2e3+5,H=1e9+7;
int n,m,a[N],C[N][N],ct[N],s[2],res=0;

int adc(int a,int b){return a+b>=H?a+b-H:a+b;}
int dec(int a,int b){return a<b?a-b+H:a-b;}
int mul(int a,int b){return 1ll*a*b%H;}
void add(int &a,int b){a=adc(a,b);}
void del(int &a,int b){a=dec(a,b);}

int qpow(int a,int b=H-2){
  int res=1;
  while(b){if(b&1) res=mul(res,a);a=mul(a,a),b>>=1;}
  return res;
}

void init(){
  for(int i=0;i<N;i++){
    C[i][0]=1;
    for(int j=1;j<=i;j++) C[i][j]=adc(C[i-1][j-1],C[i-1][j]);
  }
}

int main(){
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m,init();
  for(int i=1;i<=n;i++) cin>>a[i],ct[a[i]]++;
  sort(a+1,a+n+1);
  
  for(int i=m;i>=1;i--) s[0]+=a[i]==a[m],res-=a[i];
  for(int i=n-m+1;i<=n;i++) s[1]+=a[i]==a[n-m+1],res+=a[i];      
  cout<<res<<" ";
  
  if(a[m]==a[n-m+1]){
    int tmp=mul(C[ct[a[m]]][s[0]],C[ct[a[m]]-s[0]][s[1]]);
    if(s[0]==s[1]) cout<<mul(tmp,qpow(2));
    else cout<<tmp;
  }else cout<<mul(C[ct[a[m]]][s[0]],C[ct[a[n-m+1]]][s[1]]);
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 18528kb

input:

6 2
2 5 7 2 5 2

output:

8 6

result:

ok 2 number(s): "8 6"

Test #2:

score: 0
Accepted
time: 0ms
memory: 18684kb

input:

5 2
1 1 1 1 1

output:

0 15

result:

ok 2 number(s): "0 15"

Test #3:

score: 0
Accepted
time: 2ms
memory: 18968kb

input:

2 1
1 1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #4:

score: 0
Accepted
time: 5ms
memory: 18780kb

input:

2 1
1 2

output:

1 1

result:

ok 2 number(s): "1 1"

Test #5:

score: 0
Accepted
time: 0ms
memory: 18536kb

input:

10 4
3 3 1 2 4 6 2 4 4 1

output:

12 1

result:

ok 2 number(s): "12 1"

Test #6:

score: 0
Accepted
time: 0ms
memory: 19048kb

input:

14 3
57 57 57 57 57 57 57 57 57 57 57 57 57 57

output:

0 30030

result:

ok 2 number(s): "0 30030"

Test #7:

score: -100
Runtime Error

input:

13 5
858336 900782 858336 900782 900782 858336 900782 858336 858336 858336 858336 858336 52093

output:


result: