Submission #18580159


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,M;
int A[2020];

const ll mo=1000000007;

ll modpow(ll a, ll n=mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

ll comb(int P_,int Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%mo, q=q*i%mo,P_--;
	
	return p*modpow(q,mo-2)%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);};

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	ll space=0,sum=0;
	FOR(i,N) {
		cin>>A[i];
		space+=A[i]+1;
		sum+=A[i];
	}
	space++;
	cout<<hcomb(space,M-sum)<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Submission Info

Submission Time
Task D - Binomial Coefficient is Fun
User kmjp
Language C++ (GCC 9.2.1)
Score 600
Code Size 1438 Byte
Status AC
Exec Time 23 ms
Memory 3664 KB

Compile Error

./Main.cpp: In function ‘void solve()’:
./Main.cpp:38:8: warning: unused variable ‘j’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |        ^
./Main.cpp:38:10: warning: unused variable ‘k’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |          ^
./Main.cpp:38:12: warning: unused variable ‘l’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |            ^
./Main.cpp:38:14: warning: unused variable ‘r’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |              ^
./Main.cpp:38:16: warning: unused variable ‘x’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |                ^
./Main.cpp:38:18: warning: unused variable ‘y’ [-Wunused-variable]
   38 |  int i,j,k,l,r,x,y; string s;
      |                  ^
./Main.cpp: In function ‘int main(int, char**)’:
./Main.cpp:6:28: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
    6 | #define FOR(x,to) for(x=0;x<(to);x++)
      |                            ^
./Main.cpp:57:38: note: in expansion of macro ‘FOR’
   57 |  FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
      |                                      ^~~

Judge Result

Set Name All Sample
Score / Max Score 600 / 600 0 / 0
Status
AC × 72
AC × 2
Set Name Test Cases
All sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_31.txt, testcase_32.txt, testcase_33.txt, testcase_34.txt, testcase_35.txt, testcase_36.txt, testcase_37.txt, testcase_38.txt, testcase_39.txt, testcase_4.txt, testcase_40.txt, testcase_41.txt, testcase_42.txt, testcase_43.txt, testcase_44.txt, testcase_45.txt, testcase_46.txt, testcase_47.txt, testcase_48.txt, testcase_49.txt, testcase_5.txt, testcase_50.txt, testcase_51.txt, testcase_52.txt, testcase_53.txt, testcase_54.txt, testcase_55.txt, testcase_56.txt, testcase_57.txt, testcase_58.txt, testcase_59.txt, testcase_6.txt, testcase_60.txt, testcase_61.txt, testcase_62.txt, testcase_63.txt, testcase_64.txt, testcase_65.txt, testcase_66.txt, testcase_67.txt, testcase_68.txt, testcase_69.txt, testcase_7.txt, testcase_70.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 6 ms 3604 KB
sample_02.txt AC 2 ms 3600 KB
testcase_1.txt AC 2 ms 3496 KB
testcase_10.txt AC 2 ms 3624 KB
testcase_11.txt AC 3 ms 3592 KB
testcase_12.txt AC 2 ms 3524 KB
testcase_13.txt AC 13 ms 3520 KB
testcase_14.txt AC 19 ms 3460 KB
testcase_15.txt AC 13 ms 3524 KB
testcase_16.txt AC 13 ms 3652 KB
testcase_17.txt AC 14 ms 3560 KB
testcase_18.txt AC 12 ms 3664 KB
testcase_19.txt AC 15 ms 3612 KB
testcase_2.txt AC 2 ms 3496 KB
testcase_20.txt AC 18 ms 3660 KB
testcase_21.txt AC 19 ms 3460 KB
testcase_22.txt AC 17 ms 3580 KB
testcase_23.txt AC 13 ms 3608 KB
testcase_24.txt AC 16 ms 3588 KB
testcase_25.txt AC 16 ms 3620 KB
testcase_26.txt AC 11 ms 3592 KB
testcase_27.txt AC 14 ms 3512 KB
testcase_28.txt AC 14 ms 3584 KB
testcase_29.txt AC 12 ms 3648 KB
testcase_3.txt AC 2 ms 3584 KB
testcase_30.txt AC 20 ms 3464 KB
testcase_31.txt AC 15 ms 3588 KB
testcase_32.txt AC 18 ms 3572 KB
testcase_33.txt AC 13 ms 3584 KB
testcase_34.txt AC 17 ms 3520 KB
testcase_35.txt AC 13 ms 3572 KB
testcase_36.txt AC 15 ms 3584 KB
testcase_37.txt AC 17 ms 3464 KB
testcase_38.txt AC 13 ms 3568 KB
testcase_39.txt AC 21 ms 3612 KB
testcase_4.txt AC 2 ms 3568 KB
testcase_40.txt AC 15 ms 3580 KB
testcase_41.txt AC 20 ms 3648 KB
testcase_42.txt AC 21 ms 3588 KB
testcase_43.txt AC 14 ms 3608 KB
testcase_44.txt AC 15 ms 3624 KB
testcase_45.txt AC 12 ms 3464 KB
testcase_46.txt AC 13 ms 3624 KB
testcase_47.txt AC 14 ms 3592 KB
testcase_48.txt AC 15 ms 3500 KB
testcase_49.txt AC 15 ms 3580 KB
testcase_5.txt AC 3 ms 3500 KB
testcase_50.txt AC 18 ms 3612 KB
testcase_51.txt AC 14 ms 3612 KB
testcase_52.txt AC 15 ms 3624 KB
testcase_53.txt AC 15 ms 3620 KB
testcase_54.txt AC 2 ms 3576 KB
testcase_55.txt AC 3 ms 3624 KB
testcase_56.txt AC 2 ms 3560 KB
testcase_57.txt AC 2 ms 3508 KB
testcase_58.txt AC 2 ms 3572 KB
testcase_59.txt AC 3 ms 3628 KB
testcase_6.txt AC 2 ms 3504 KB
testcase_60.txt AC 2 ms 3528 KB
testcase_61.txt AC 2 ms 3608 KB
testcase_62.txt AC 2 ms 3572 KB
testcase_63.txt AC 2 ms 3508 KB
testcase_64.txt AC 2 ms 3580 KB
testcase_65.txt AC 2 ms 3592 KB
testcase_66.txt AC 2 ms 3560 KB
testcase_67.txt AC 2 ms 3584 KB
testcase_68.txt AC 2 ms 3572 KB
testcase_69.txt AC 2 ms 3648 KB
testcase_7.txt AC 2 ms 3648 KB
testcase_70.txt AC 2 ms 3648 KB
testcase_8.txt AC 14 ms 3576 KB
testcase_9.txt AC 23 ms 3560 KB