QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841915#9967. Imbalanced Teamsucup-team3555#WA 5ms25512kbC++201.1kb2025-01-04 08:48:582025-01-04 08:48:59

Judging History

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

  • [2025-01-04 08:48:59]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:25512kb
  • [2025-01-04 08:48:58]
  • 提交

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*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: 0ms
memory: 21172kb

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: 5ms
memory: 20532kb

input:

5 2
1 1 1 1 1

output:

0 15

result:

ok 2 number(s): "0 15"

Test #3:

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

input:

2 1
1 1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #4:

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

input:

2 1
1 2

output:

1 1

result:

ok 2 number(s): "1 1"

Test #5:

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

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: 3ms
memory: 20648kb

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: 0
Accepted
time: 2ms
memory: 21656kb

input:

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

output:

976027 280

result:

ok 2 number(s): "976027 280"

Test #8:

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

input:

14 4
447923 447923 447923 211106 447923 447923 447923 447923 16966 447923 211106 515550 211106 211106

output:

1209035 224

result:

ok 2 number(s): "1209035 224"

Test #9:

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

input:

2000 935
57596 988638 30477 956599 52986 460052 987863 291984 947848 109335 541003 338365 939256 297365 926486 944912 700042 810595 412192 37130 343207 311311 681629 48155 319677 435667 731251 919378 254216 893282 661237 740159 787502 501360 517533 349880 565298 536545 192793 18666 425164 856977 536...

output:

493241703 1

result:

ok 2 number(s): "493241703 1"

Test #10:

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

input:

2000 1000
101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101493 101...

output:

0 36237869

result:

ok 2 number(s): "0 36237869"

Test #11:

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

input:

2000 1000
834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834985 834...

output:

95671357 1001

result:

ok 2 number(s): "95671357 1001"

Test #12:

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

input:

2000 1000
999763 998795 997229 996607 995585 995585 995080 995080 995080 994251 994251 994251 994169 994158 994051 993410 993410 993410 993410 993410 993410 993410 993410 992448 992314 992176 990170 989664 989638 987205 987205 987205 987205 987205 987205 987067 986997 986233 985924 985707 985180 985...

output:

85351652 417058531

result:

ok 2 number(s): "85351652 417058531"

Test #13:

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

input:

2000 1000
220336 697950 570674 245907 697950 409648 697950 245907 697950 245907 245907 245907 496369 697950 697950 697950 245907 435446 697950 245907 697950 245907 697950 317643 245907 245907 697950 697950 697950 245907 697950 697950 697950 697950 697950 220336 412219 697950 245907 245907 697950 697...

output:

406826343 1001

result:

ok 2 number(s): "406826343 1001"

Test #14:

score: -100
Wrong Answer
time: 2ms
memory: 23144kb

input:

2000 1000
824739 824739 511894 511894 511894 824739 824739 511894 511894 511894 511894 511894 824739 511894 422607 824739 824739 824739 511894 824739 824739 824739 824739 824739 511894 824739 824739 824739 824739 824739 824739 511894 511894 824739 511894 824739 511894 824739 511894 824739 511894 824...

output:

312778791 1

result:

wrong answer 2nd numbers differ - expected: '2', found: '1'