QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#847530#9967. Imbalanced TeamsZawos#WA 8ms23528kbC++231.9kb2025-01-08 04:09:372025-01-08 04:09:37

Judging History

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

  • [2025-01-08 04:09:37]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:23528kb
  • [2025-01-08 04:09:37]
  • 提交

answer

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vi=vector<int>;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
//上
const ll MOD = 1e9+7;
ll binpow(ll a,ll b){
    ll mul = a;
    ll ans = 1;
    while(b){
        if(b&1){
            ans = mul*ans%MOD;
        }
        b/=2;
        mul = mul*mul%MOD;
    }
    return ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<vector<ll>> C(2001);
    C[0].push_back(1);
    for(int i = 1; i <=2000;i++){
        C[i].push_back(1);
        for(int j = 1; j <i;j++) C[i].push_back((C[i-1][j-1]+C[i-1][j])%MOD);
        C[i].push_back(1);
    }
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    FOR(i,0,n) cin >> v[i];
    sort(v.begin(),v.end());
    ll ans = 0;
    for(int i = 0; i < k; i++) ans-=v[i];
    for(int i = n-1; i> n-1-k;i--) ans += v[i];
    ll r = 0;
    if(v[k-1] == v[n-k]){

            int a = 0,b=0,c = 0,d= 0;
            for(int i = 0; i < k; i++) if(v[i] == v[k-1]) a++;
            for(int i = 0; i < n; i++) if(v[i] == v[k-1]) b++;
            for(int i = n-k; i < n; i++) if(v[i] == v[n-k]) c++;
            r = C[b][a+c]*C[a+c][c]%MOD;
            if(v[0] == v[n-1]) r = r*binpow(2,MOD-2)%MOD;
            cout <<ans<<" "<<r<<'\n';
        
    }else{
        int a = 0,b=0,c = 0,d= 0;
        for(int i = 0; i < k; i++) if(v[i] == v[k-1]) a++;
        for(int i = 0; i < n; i++) if(v[i] == v[k-1]) b++;
        for(int i = 0; i < n; i++) if(v[i] == v[n-k]) d++;
        for(int i = n-k; i < n; i++) if(v[i] == v[n-1]) c++;
        r = C[b][a]*C[d][c]%MOD;
        cout <<ans <<" "<<r<<'\n';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 8ms
memory: 23416kb

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

input:

5 2
1 1 1 1 1

output:

0 15

result:

ok 2 number(s): "0 15"

Test #3:

score: 0
Accepted
time: 7ms
memory: 23528kb

input:

2 1
1 1

output:

0 1

result:

ok 2 number(s): "0 1"

Test #4:

score: 0
Accepted
time: 7ms
memory: 23468kb

input:

2 1
1 2

output:

1 1

result:

ok 2 number(s): "1 1"

Test #5:

score: -100
Wrong Answer
time: 3ms
memory: 23248kb

input:

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

output:

12 3

result:

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