{"problem":{"name":"Lucky Numbers","description":{"content":"You are given a sequence of $N-1$ integers $S = (S_1, S_2, \\ldots, S_{N-1})$, and $M$ distinct integers $X_1, X_2, \\ldots, X_M$, which are called _lucky numbers_. A sequence of $N$ integers $A = (A_1,","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":4000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc255_e"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence of $N-1$ integers $S = (S_1, S_2, \\ldots, S_{N-1})$, and $M$ distinct integers $X_1, X_2, \\ldots, X_M$, which are called _lucky numbers_.\nA sequence of $N$ integers $A = (A_1, A_2, \\ldots, A_N)$ satisfying the following condition is called a _good sequence_.\n\n> $A_i + A_{i+1} = S_i$ holds for every $i = 1, 2, \\ldots, N-1$.\n\nFind the maximum possible number of terms that are lucky numbers in a good sequence $A$, that is, the maximum possible number of integers $i$ between $1$ and $N$ such that $A_i \\in \\lbrace X_1, X_2, \\ldots, X_M \\rbrace$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 10^5$\n*   $1 \\leq M \\leq 10$\n*   $-10^9 \\leq S_i \\leq 10^9$\n*   $-10^9 \\leq X_i \\leq 10^9$\n*   $X_1 \\lt X_2 \\lt \\cdots \\lt X_M$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$S_1$ $S_2$ $\\ldots$ $S_{N-1}$\n$X_1$ $X_2$ $\\ldots$ $X_M$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc255_e","tags":[],"sample_group":[["9 2\n2 3 3 4 -4 -7 -4 -1\n-1 5","4\n\nA good sequence $A = (3, -1, 4, -1, 5, -9, 2, -6, 5)$ contains four terms that are lucky numbers: $A_2, A_4, A_5, A_9$, which is the maximum possible count."],["20 10\n-183260318 206417795 409343217 238245886 138964265 -415224774 -499400499 -313180261 283784093 498751662 668946791 965735441 382033304 177367159 31017484 27914238 757966050 878978971 73210901\n-470019195 -379631053 -287722161 -231146414 -84796739 328710269 355719851 416979387 431167199 498905398","8"]],"created_at":"2026-03-03 11:01:14"}}