結果

問題 No.1238 選抜クラス
ユーザー furafura
提出日時 2020-09-26 17:22:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 1,812 bytes
コンパイル時間 2,292 ms
コンパイル使用メモリ 204,276 KB
実行使用メモリ 11,188 KB
最終ジャッジ日時 2023-09-11 21:30:36
合計ジャッジ時間 4,109 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 3 ms
4,380 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 13 ms
11,004 KB
testcase_18 AC 13 ms
10,732 KB
testcase_19 AC 13 ms
11,092 KB
testcase_20 AC 13 ms
10,684 KB
testcase_21 AC 13 ms
10,440 KB
testcase_22 AC 14 ms
10,880 KB
testcase_23 AC 13 ms
11,004 KB
testcase_24 AC 13 ms
11,092 KB
testcase_25 AC 13 ms
11,188 KB
testcase_26 AC 14 ms
10,948 KB
testcase_27 AC 13 ms
10,980 KB
testcase_28 AC 13 ms
11,036 KB
testcase_29 AC 13 ms
10,996 KB
testcase_30 AC 5 ms
5,384 KB
testcase_31 AC 9 ms
7,452 KB
testcase_32 AC 10 ms
9,184 KB
testcase_33 AC 3 ms
4,376 KB
testcase_34 AC 11 ms
9,952 KB
testcase_35 AC 7 ms
6,244 KB
testcase_36 AC 4 ms
4,636 KB
testcase_37 AC 5 ms
5,912 KB
testcase_38 AC 13 ms
10,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int main(){
	int n,k; scanf("%d%d",&n,&k);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]-=k;

	vector dp(n+1,vector(20001,mint(0)));
	const int ofs=10000;
	dp[0][ofs]=1;
	rep(i,n){
		for(int x=-10000;x<=10000;x++){
			dp[i+1][x+ofs]+=dp[i][x+ofs];
			if(-10000<=x+a[i] && x+a[i]<=10000){
				dp[i+1][x+a[i]+ofs]+=dp[i][x+ofs];
			}
		}
	}

	mint ans=-1;
	rep(x,10001) ans+=dp[n][x+ofs];
	cout<<ans<<'\n';

	return 0;
}
0