結果
問題 | No.137 貯金箱の焦り |
ユーザー | lgswdn |
提出日時 | 2023-06-12 09:09:50 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,229 ms / 5,000 ms |
コード長 | 1,908 bytes |
コンパイル時間 | 2,062 ms |
コンパイル使用メモリ | 200,196 KB |
実行使用メモリ | 41,612 KB |
最終ジャッジ日時 | 2023-09-02 05:31:52 |
合計ジャッジ時間 | 9,411 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 6 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 30 ms
4,600 KB |
testcase_05 | AC | 16 ms
4,384 KB |
testcase_06 | AC | 17 ms
4,380 KB |
testcase_07 | AC | 9 ms
4,376 KB |
testcase_08 | AC | 9 ms
4,380 KB |
testcase_09 | AC | 19 ms
4,380 KB |
testcase_10 | AC | 9 ms
4,380 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 1,229 ms
41,612 KB |
testcase_13 | AC | 713 ms
25,780 KB |
testcase_14 | AC | 635 ms
23,520 KB |
testcase_15 | AC | 544 ms
20,712 KB |
testcase_16 | AC | 520 ms
19,860 KB |
testcase_17 | AC | 154 ms
9,020 KB |
testcase_18 | AC | 488 ms
19,176 KB |
testcase_19 | AC | 596 ms
22,228 KB |
testcase_20 | AC | 3 ms
4,376 KB |
testcase_21 | AC | 253 ms
12,128 KB |
testcase_22 | AC | 29 ms
4,612 KB |
testcase_23 | AC | 27 ms
4,528 KB |
testcase_24 | AC | 119 ms
7,868 KB |
testcase_25 | AC | 343 ms
14,788 KB |
ソースコード
#include<bits/stdc++.h> #define fi first #define se second #define eb emplace_back #define mp make_pair using namespace std; typedef long double ld; typedef long long ll; typedef unsigned long long ull; typedef __int128 i128; template<typename T,typename U> T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);} template<typename T,typename U> T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);} template<class T,class S> bool chmax(T &a,const S b) {return (a<b?a=b,1:0);} template<class T,class S> bool chmin(T &a,const S b) {return (a>b?a=b,1:0);} int popcnt(int x) {return __builtin_popcount(x);} int popcnt(ll x) {return __builtin_popcountll(x);} int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));} int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));} int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));} int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));} #define int long long #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vp; typedef tuple<int,int,int> tiii; int read() { int x=0,w=1; char c=getchar(); while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();} while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();} return x*w; } const int N=55,M=50005,mod=1234567891; int n,m,a[N],f[N][M][2],sum; void pls(int &x,int y) {x+=y; if(x>=mod) x-=mod;} signed main() { n=read(), m=read(); f[0][0][0]=1; rep(i,1,n) a[i]=read(), sum+=2*a[i]; rep(h,0,60) { if(h) { rep(i,0,n-1) rep(j,0,sum) rep(k,0,1) f[i][j][k]=0; rep(j,0,sum) pls(f[0][j/2][j%2],f[n][j][(m>>(h-1))&1]); rep(j,0,sum) rep(k,0,1) f[n][j][k]=0; } rep(i,0,n-1) rep(j,0,sum) rep(k,0,1) { pls(f[i+1][j][k],f[i][j][k]); int nj=j+a[i+1]/2+(k+a[i+1]%2)/2; if(nj<=sum) pls(f[i+1][nj][k^(a[i+1]%2)],f[i][j][k]); } } printf("%lld\n",f[n][0][(m>>60)&1]); return 0; }