結果
問題 | No.137 貯金箱の焦り |
ユーザー | MahdiSiyam |
提出日時 | 2023-04-30 23:16:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 236 ms / 5,000 ms |
コード長 | 912 bytes |
コンパイル時間 | 1,756 ms |
コンパイル使用メモリ | 168,000 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-19 12:54:59 |
合計ジャッジ時間 | 4,759 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #ifdef LOKAL #include "DEBUG_TEMPLATE.h" #else #define HERE #define debug(args...) #endif typedef pair<int,int> pii; #define ALL(x) x.begin(),x.end() const int N = 50000 +15; const ll oo = 1234567891LL; int n; ll m; int sum = 0; int a[N]; ll dp[N]; void solve() { debug(oo*oo); cin>>n>>m; for(int i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } dp[0]=1; while(m) { for(int i=0;i<n;i++) for(int j=N-1;j>=a[i];j--) dp[j] = (dp[j] + dp[j-a[i]])%oo; for(int i=0;i<N;i++) { int x = i*2+(m&1); if(x<N) dp[i] = dp[x]; else dp[i]=0; } m/=2; } cout<<dp[0]<<"\n"; } /* */ int32_t main() { #ifndef LOKAL ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif int T=1; // cin>>T; while(T--) { solve(); } return 0; }