QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#842727 | #9967. Imbalanced Teams | ucup-team3474# | WA | 5ms | 42720kb | C++23 | 1.2kb | 2025-01-04 14:18:51 | 2025-01-04 14:18:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int N=2e6+10,mod=1e9+7;
ll n,m,k;
ll ans;
ll ny;
ll a[N];
ll cnt[N];
ll cnt2[N],cnt3[N];
ll C[2025][2025];
void __(){
cin>>n>>k;
for(int i=1;i<=n;i++){
cin>>a[i];
cnt[a[i]]++;
}
sort(a+1,a+1+n);
ll ans=0;
for(int i=1;i<=n;i++){
if(i<=k) {
ans-=a[i];
cnt2[a[i]]++;
}
if(i+k>n){
ans+=a[i];
cnt3[a[i]]++;
}
}
cout<<ans<<" ";
for(int i=0;i<=2020;i++){
C[i][0]=1;
}
for(int i=1;i<=2020;i++){
for(int j=1;j<=i;j++){
C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
}
}
// for(int i=1;i<=n;i++) cnt[a[i]]++;
// cout<<C[5][2]*C[3][2]*ny%mod<<endl;
ll num=1;
int u=a[k],uu=a[n-k+1];
num=C[cnt[u]][cnt2[u]];
if(u==uu){
num=num*C[cnt[u]-cnt2[u]][cnt3[uu]]%mod;
}else num=num*C[cnt[uu]][cnt3[uu]]%mod;
if(cnt2[u]==k&&cnt3[uu]==k) num=num*ny%mod;
cout<<num<<endl;
}
int main()
{
int _=1;
ny=mod/2+1;
// cin>>_;
while(_--){
__();
}
}
//51423
详细
Test #1:
score: 100
Accepted
time: 5ms
memory: 42668kb
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: 3ms
memory: 42720kb
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: 40840kb
input:
2 1 1 1
output:
0 1
result:
ok 2 number(s): "0 1"
Test #4:
score: -100
Wrong Answer
time: 5ms
memory: 40836kb
input:
2 1 1 2
output:
1 500000004
result:
wrong answer 2nd numbers differ - expected: '1', found: '500000004'