結果
| 問題 |
No.137 貯金箱の焦り
|
| コンテスト | |
| ユーザー |
chocorusk
|
| 提出日時 | 2018-12-11 10:01:59 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,116 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 98,524 KB |
| 実行使用メモリ | 25,344 KB |
| 最終ジャッジ日時 | 2024-09-19 18:31:39 |
| 合計ジャッジ時間 | 8,500 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 9 TLE * 1 -- * 13 |
ソースコード
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1234567891;
int main()
{
int n; ll m;
cin>>n>>m;
int a[50];
for(int i=0; i<n; i++) cin>>a[i];
ll dp0[51][25001]={};
dp0[0][0]=1;
for(int i=0; i<n; i++){
for(int j=0; j<=25000; j++){
dp0[i+1][j]+=dp0[i][j];
if(j>=a[i]) dp0[i+1][j]+=dp0[i][j-a[i]];
dp0[i+1][j]%=MOD;
}
}
vector<int> ind[2];
for(int k=0; k<=25000; k++){
if(dp0[n][k]==0) continue;
ind[k&1].push_back(k);
}
ll dp[61][25001]={};
dp[0][0]=1;
for(int i=0; i<60; i++){
int par=((m&(1ll<<i))?1:0);
for(int j=0; j<=25000; j++){
if(dp[i][j]==0) continue;
for(auto k:ind[(j+par)&1]){
if(dp0[n][k]==0) continue;
dp[i+1][(j+k)/2]+=(dp[i][j]*dp0[n][k]);
dp[i+1][(j+k)/2]%=MOD;
}
}
}
cout<<dp[60][0]<<endl;
return 0;
}
chocorusk