結果

問題 No.2581 [Cherry Anniversary 3] 28輪の桜のブーケ
ユーザー titiatitia
提出日時 2023-12-09 01:54:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,011 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2023-12-09 01:54:30
合計ジャッジ時間 5,380 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
72,832 KB
testcase_01 AC 106 ms
77,824 KB
testcase_02 TLE -
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

from collections import Counter

from bisect import bisect_left

M=int(input())
G=list(map(int,input().split()))
H=list(map(int,input().split()))

DP1=[(0,0)]

for i in range(14):
    NDP1=[]
    for x,y in DP1:
        NDP1.append((x+1,(y+G[i])%M))
        NDP1.append((x,(y+H[i])%M))

    DP1=NDP1

DP2=[(0,0)]

for i in range(14,28):
    NDP2=[]
    for x,y in DP2:
        NDP2.append((x+1,(y+G[i])%M))
        NDP2.append((x,(y+H[i])%M))

    DP2=NDP2

LIST1=[[] for i in range(29)]

for x,y in DP1:
    LIST1[x].append(y)

for i in range(29):
    LIST1[i]=Counter(LIST1[i])

LIST2=[[] for i in range(29)]

for x,y in DP2:
    LIST2[x].append(y)

for i in range(29):
    LIST2[i]=Counter(LIST2[i])

Q=int(input())
for tests in range(Q):
    K,X=map(int,input().split())

    ANS=0

    for i in range(K+1):
        for c in LIST1[i]:
            for c2 in LIST2[K-i]:
                if (c+c2)%M>=X:
                    ANS+=LIST1[i][c]*LIST2[K-i][c2]

    print(ANS)
0