QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#841947 | #9967. Imbalanced Teams | ucup-team1004# | WA | 0ms | 4100kb | C++20 | 1.9kb | 2025-01-04 09:00:49 | 2025-01-04 09:00:53 |
Judging History
answer
#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=2e3+5,M=(1<<8)+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int n,k,A[N];
ll C[N][N];
void Solve(){
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++) scanf("%d",&A[i]);
sort(A+1,A+n+1);
for(int i=0;i<=n;i++) for(int j=C[i][0]=1;j<=n;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
if(A[1]==A[n]){
printf("0 %lld\n",C[n][k]*C[n-k][k]%mod*(mod+1>>1)%mod);
return;
}
ll sum=0;
for(int i=1;i<=k;i++) sum+=A[n-i+1]-A[i];
ll ans=0;
if(A[k]==A[n-k+1]){
int l=k,r=n-k+1;
while(A[l-1]==A[l]) l--;
while(A[r+1]==A[r]) r++;
ans=C[r-l+1][k-(l-1)]*C[r-l+1-(k-(l-1))][k-(n-r)]%mod;
}else{
int l=k,r=k;
while(A[l-1]==A[l]) l--;
while(A[r+1]==A[r]) r++;
ans=C[r-l+1][k-(l-1)];
l=n-k+1,r=n-k+1;
while(A[l-1]==A[l]) l--;
while(A[r+1]==A[r]) r++;
ans=ans*C[r-l+1][k-(n-r)]%mod;
}
printf("%lld %lld\n",sum,ans);
}
int main(){
int t=1;
// scanf("%d",&t);
while(t--) Solve();
cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 4100kb
input:
6 2 2 5 7 2 5 2
output:
8 608263266
result:
wrong answer 2nd numbers differ - expected: '6', found: '608263266'