QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#843334 | #9967. Imbalanced Teams | ucup-team139# | WA | 1ms | 3728kb | C++14 | 1021b | 2025-01-04 18:02:37 | 2025-01-04 18:02:40 |
Judging History
answer
#include <bits/stdc++.h>
#define int int64_t
using namespace std;
const int m = 1000000009;
int inv(int a) {
return a <= 1 ? a : m - (long long)(m/a) * inv(m % a) % m;
}
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
int n,k;
cin>>n>>k;
vector<int> v(n);
vector<int> fact(n+1,1);
for(int i=1; i<=n; ++i) fact[i]=i*fact[i-1]%m;
for(auto &i:v) cin>>i;
sort(v.begin(),v.end());
int ans = 0;
int lv=-1,ln=0;
for(int i=0; i<k; ++i) {
if(v[i]!=lv) ln=0;
lv=v[i];
ln++;
ans-=v[i];
}
int rv=-1, rn=0;
for(int i=n-1; i>=n-k; --i) {
if(v[i]!=rv) rn=0;
rv=v[i];
rn++;
ans+=v[i];
}
int nlv=0,nrv=0;
for(int i=0; i<n; ++i) {
nlv+=(v[i]==lv);
nrv+=(v[i]==rv);
}
if(lv==rv) {
nrv-=ln;
}
int cl = fact[nlv]*inv(fact[ln])%m*inv(fact[nlv-ln])%m;
int cr = fact[nrv]*inv(fact[rn])%m*inv(fact[nrv-rn])%m;
int cnt = cl*cr%m;
if(v[0]==v[n-1]) cnt = cnt*inv(2)%m;
cerr<<ln<<' '<<rn<<' '<<nlv<<' '<<nrv<<' '<<cl<<' '<<cr<<endl;
cout<<ans<<' '<<cnt<<endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3392kb
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: 3704kb
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: 3728kb
input:
2 1 1 1
output:
0 1
result:
ok 2 number(s): "0 1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
2 1 1 2
output:
1 1
result:
ok 2 number(s): "1 1"
Test #5:
score: 0
Accepted
time: 0ms
memory: 3532kb
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: 3496kb
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: 0ms
memory: 3508kb
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: 3428kb
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: 1ms
memory: 3612kb
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: -100
Wrong Answer
time: 1ms
memory: 3480kb
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 879451504
result:
wrong answer 2nd numbers differ - expected: '36237869', found: '879451504'