Submission #28863607


Source Code Expand

#include<bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int mo=998244353;
inline int read(){
	int x=0,f=1;char c=getchar();
	while(c<48){if(c=='-')f=0;c=getchar();}
	while(c>=48) x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f?x:-x;
}
int n,k;
int a[N];
int f[N],finv[N],inv[N];
inline int calc2(int n,int m){
	int res=1;
	for(int i=n;i>=n-m+1;i--) res=res*i%mo;
	return res*finv[m]%mo;
}
signed main(){
	f[0]=f[1]=finv[0]=finv[1]=inv[1]=1;
	for(int i=2;i<=1e5;i++){
		f[i]=f[i-1]*i%mo;
		inv[i]=mo-(mo/i)*inv[mo%i]%mo;
		finv[i]=finv[i-1]*inv[i]%mo;
	}
	n=read();k=read();
	int sum=0;
	for(int i=1;i<=n;i++){
		a[i]=read();
		if(i>1) sum+=a[i];
	}
	if(a[1]-sum-k<0){
		cout<<0<<endl;
		return 0;
	}
	int res=calc2(a[1]-sum-1,k-1);
	for(int i=2;i<=n;i++) res=res*calc2(a[i]+k-1,k-1)%mo;
	cout<<res<<endl;
	return 0;
}

Submission Info

Submission Time
Task C - The Majority
User NeymarJr10
Language C++ (GCC 9.2.1)
Score 500
Code Size 889 Byte
Status AC
Exec Time 84 ms
Memory 6720 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 33
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 15 ms 5976 KiB
random_02.txt AC 9 ms 6540 KiB
random_03.txt AC 7 ms 5876 KiB
random_04.txt AC 84 ms 6584 KiB
random_05.txt AC 7 ms 5964 KiB
random_06.txt AC 12 ms 6676 KiB
random_07.txt AC 11 ms 5876 KiB
random_08.txt AC 81 ms 6656 KiB
random_09.txt AC 7 ms 5748 KiB
random_10.txt AC 11 ms 6680 KiB
random_11.txt AC 9 ms 5968 KiB
random_12.txt AC 83 ms 6720 KiB
random_13.txt AC 78 ms 6632 KiB
random_14.txt AC 18 ms 6528 KiB
random_15.txt AC 54 ms 6264 KiB
random_16.txt AC 35 ms 6540 KiB
random_17.txt AC 29 ms 6640 KiB
random_18.txt AC 35 ms 6116 KiB
random_19.txt AC 55 ms 6488 KiB
random_20.txt AC 10 ms 5924 KiB
random_21.txt AC 35 ms 6148 KiB
random_22.txt AC 10 ms 5956 KiB
random_23.txt AC 17 ms 6088 KiB
random_24.txt AC 30 ms 6060 KiB
random_25.txt AC 8 ms 5976 KiB
random_26.txt AC 12 ms 6280 KiB
random_27.txt AC 9 ms 5932 KiB
random_28.txt AC 12 ms 6548 KiB
random_29.txt AC 13 ms 6644 KiB
random_30.txt AC 12 ms 6476 KiB
sample_01.txt AC 10 ms 5816 KiB
sample_02.txt AC 10 ms 5908 KiB
sample_03.txt AC 10 ms 5808 KiB