{"problem":{"name":"Max Multiple","description":{"content":"You are given a sequence of non-negative integers $A=(a_1,a_2,\\ldots,a_N)$. Let $S$ be the set of non-negative integers that can be the sum of $K$ terms in $A$ (with distinct indices). Find the greate","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc281_d"},"statements":[{"statement_type":"Markdown","content":"You are given a sequence of non-negative integers $A=(a_1,a_2,\\ldots,a_N)$.\nLet $S$ be the set of non-negative integers that can be the sum of $K$ terms in $A$ (with distinct indices).\nFind the greatest multiple of $D$ in $S$. If there is no multiple of $D$ in $S$, print `-1` instead.\n\n## Constraints\n\n*   $1 \\leq K \\leq N \\leq 100$\n*   $1 \\leq D \\leq 100$\n*   $0 \\leq a_i \\leq 10^9$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $K$ $D$\n$a_1$ $\\ldots$ $a_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc281_d","tags":[],"sample_group":[["4 2 2\n1 2 3 4","6\n\nHere are all the ways to choose two terms in $A$.\n\n*   Choose $a_1$ and $a_2$, whose sum is $1+2=3$.\n*   Choose $a_1$ and $a_3$, whose sum is $1+3=4$.\n*   Choose $a_1$ and $a_4$, whose sum is $1+4=5$.\n*   Choose $a_2$ and $a_3$, whose sum is $2+3=5$.\n*   Choose $a_2$ and $a_4$, whose sum is $2+4=6$.\n*   Choose $a_3$ and $a_4$, whose sum is $3+4=7$.\n\nThus, we have $S={3,4,5,6,7}$. The greatest multiple of $2$ in $S$ is $6$, so you should print $6$."],["3 1 2\n1 3 5","\\-1\n\nIn this example, we have $S={1,3,5}$. Nothing in $S$ is a multiple of $2$, so you should print `-1`."]],"created_at":"2026-03-03 11:01:14"}}