結果

問題 No.1238 選抜クラス
ユーザー kotatsugame
提出日時 2020-09-26 08:06:31
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 64,256 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 17:33:50
合計ジャッジ時間 1,681 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
const int off=10000;
const long mod=1e9+7;
long dp[20202];
int N,K;
main()
{
	cin>>N>>K;
	dp[off]=1;
	for(int i=0;i<N;i++)
	{
		int A;cin>>A;A-=K;
		if(A>=0)
		{
			for(int j=20201;j>=A;j--)(dp[j]+=dp[j-A])%=mod;
		}
		else
		{
			for(int j=-A;j<20202;j++)(dp[j+A]+=dp[j])%=mod;
		}
	}
	long ans=mod-1;
	for(int j=off;j<20202;j++)ans+=dp[j];
	cout<<ans%mod<<endl;
}
0