結果
問題 | No.2581 [Cherry Anniversary 3] 28輪の桜のブーケ |
ユーザー |
![]() |
提出日時 | 2023-12-09 01:54:21 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,011 bytes |
コンパイル時間 | 406 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 78,720 KB |
最終ジャッジ日時 | 2024-09-27 03:25:39 |
合計ジャッジ時間 | 9,074 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 2 -- * 28 |
ソースコード
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)