結果
問題 | No.1238 選抜クラス |
ユーザー |
![]() |
提出日時 | 2021-09-02 00:12:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 971 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 68,736 KB |
最終ジャッジ日時 | 2024-11-28 21:32:33 |
合計ジャッジ時間 | 4,124 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**9 # md = 998244353 md = 10**9+7 mx = 10003 n, k = LI() aa = LI() aa = [a-k for a in aa] dp = [0]*(mx*2+5) dp[0] = 1 for a in aa: if a >= 0: s, t, d = mx, -mx, -1 else: s, t, d = -mx, mx, 1 for j in range(s, t, d): if j+a > mx or j+a < -mx: continue dp[j+a] += dp[j] dp[j+a] %= md ans = -1 for j in range(mx): ans += dp[j] ans %= md print(ans)