結果

問題 No.137 貯金箱の焦り
ユーザー sigma425sigma425
提出日時 2017-09-16 03:00:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,467 ms / 5,000 ms
コード長 949 bytes
コンパイル時間 2,823 ms
コンパイル使用メモリ 143,884 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 18:09:07
合計ジャッジ時間 16,705 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,380 KB
testcase_01 AC 13 ms
4,376 KB
testcase_02 AC 122 ms
4,380 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 150 ms
4,376 KB
testcase_05 AC 54 ms
4,376 KB
testcase_06 AC 143 ms
4,376 KB
testcase_07 AC 96 ms
4,380 KB
testcase_08 AC 101 ms
4,376 KB
testcase_09 AC 150 ms
4,376 KB
testcase_10 AC 87 ms
4,376 KB
testcase_11 AC 34 ms
4,380 KB
testcase_12 AC 1,467 ms
4,376 KB
testcase_13 AC 198 ms
4,376 KB
testcase_14 AC 1,445 ms
4,376 KB
testcase_15 AC 1,265 ms
4,376 KB
testcase_16 AC 1,294 ms
4,376 KB
testcase_17 AC 753 ms
4,376 KB
testcase_18 AC 1,214 ms
4,376 KB
testcase_19 AC 1,441 ms
4,380 KB
testcase_20 AC 59 ms
4,380 KB
testcase_21 AC 943 ms
4,380 KB
testcase_22 AC 298 ms
4,380 KB
testcase_23 AC 259 ms
4,376 KB
testcase_24 AC 644 ms
4,380 KB
testcase_25 AC 1,120 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
ll mod = 1234567891;
int N;
ll M;
ll a[50];
ll dp[51000];
int main(){
	cin>>N>>M;
	rep(i,N) cin>>a[i];
	dp[0] = 1;
	while(M){
		rep(i,N){
			for(int x = 50000;x>=a[i];x--){
				dp[x] += dp[x-a[i]];
				dp[x] %= mod;
			}
		}
		rep(x,25001) dp[x] = dp[x*2+M%2];
		rep(x,25000) dp[x+25000] = 0;
		M/=2;
	}
	cout<<dp[0]<<endl;
}
0