結果
問題 | No.137 貯金箱の焦り |
ユーザー | chineristAC |
提出日時 | 2022-02-27 00:55:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,090 ms / 5,000 ms |
コード長 | 1,374 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 87,228 KB |
実行使用メモリ | 102,960 KB |
最終ジャッジ日時 | 2023-09-18 06:06:53 |
合計ジャッジ時間 | 9,208 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 131 ms
79,820 KB |
testcase_01 | AC | 123 ms
79,056 KB |
testcase_02 | AC | 131 ms
79,800 KB |
testcase_03 | AC | 121 ms
74,520 KB |
testcase_04 | AC | 147 ms
80,060 KB |
testcase_05 | AC | 135 ms
79,928 KB |
testcase_06 | AC | 143 ms
79,976 KB |
testcase_07 | AC | 137 ms
80,044 KB |
testcase_08 | AC | 137 ms
79,716 KB |
testcase_09 | AC | 142 ms
80,308 KB |
testcase_10 | AC | 138 ms
79,876 KB |
testcase_11 | AC | 121 ms
74,716 KB |
testcase_12 | AC | 1,090 ms
102,960 KB |
testcase_13 | AC | 210 ms
82,204 KB |
testcase_14 | AC | 677 ms
91,968 KB |
testcase_15 | AC | 605 ms
91,928 KB |
testcase_16 | AC | 544 ms
91,076 KB |
testcase_17 | AC | 286 ms
81,712 KB |
testcase_18 | AC | 519 ms
90,912 KB |
testcase_19 | AC | 602 ms
91,332 KB |
testcase_20 | AC | 138 ms
79,840 KB |
testcase_21 | AC | 354 ms
81,772 KB |
testcase_22 | AC | 165 ms
80,420 KB |
testcase_23 | AC | 158 ms
80,148 KB |
testcase_24 | AC | 243 ms
81,512 KB |
testcase_25 | AC | 418 ms
89,048 KB |
ソースコード
class DualSegmentTree: def __init__(self, n, segfunc, ide_ele): self.segfunc = segfunc self.ide_ele = ide_ele self.num = 1 << (n - 1).bit_length() self.tree = [ide_ele] * 2 * self.num def update(self,l,r,x): l += self.num r += self.num while l < r: if l & 1: self.tree[l] = self.segfunc(self.tree[l],x) l += 1 if r & 1: self.tree[r-1] = self.segfunc(self.tree[r-1],x) l >>= 1 r >>= 1 def __getitem__(self,idx): idx += self.num res = self.ide_ele while idx: res = self.segfunc(res,self.tree[idx]) idx>>=1 return res import sys,random,bisect from collections import deque,defaultdict from heapq import heapify,heappop,heappush from itertools import permutations from math import log,gcd input = lambda :sys.stdin.readline().rstrip() mi = lambda :map(int,input().split()) li = lambda :list(mi()) mod = 1234567891 N,M = mi() A = li() S = sum(A) dp = [0] * (2*S+1) dp[0] = 1 while M: for i in range(N): for s in range(2*S+1-A[i])[::-1]: dp[s+A[i]] += dp[s] dp[s+A[i]] %= mod ndp = [0] * (2*S+1) for s in range(2*S+1): if s&1==M&1: ndp[s>>1] = dp[s] dp = ndp M >>= 1 print(dp[0])