E. K 倍子数组 / K-Divisible Subarrays

    传统题 2000ms 256MiB

K 倍子数组 / K-Divisible Subarrays

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

You are given a sequence of length NN consisting of non-negative integers: A=(A1,A2,…,AN)A=(A _ 1,A _ 2,\ldots,A _ N).

Define the score of a sequence of length 11 or more consisting of sequences of non-negative integers, S=(S1,S2,…,Sk)S=(S _ 1,S _ 2,\ldots,S _ k), as the number of sequences Si (1≤i≤k)S _ i\ (1\le i\le k) whose sum of elements is divisible by KK.

Find the maximum possible score of a sequence of non-negative integer sequences obtained by dividing AA into one or more contiguous subsequences. Here, dividing a sequence AA of length NN into one or more contiguous subsequences means choosing a sequence of integers $l=(l _ 1,l _ 2,\ldots,l _ k)\ (1=l _ 1\lt l _ 2\lt\cdots\lt l _ k\le N)$ of length 11 or more, and forming the following kk sequences.

  • $(A _ {l _ i},A _ {l _ i+1},\ldots,A _ {l _ {i+1}-1})\ (1\le i\le k)$ (Here, let lk+1=N+1l _ {k+1}=N+1.)

Constraints

  • 1≤N≤2×1051\le N\le2\times10 ^ 5
  • 1≤K≤1091\le K\le10 ^ 9
  • 0≤Ai<K0\le A _ i\lt K
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

  • NN KK
  • A1A _ 1 A2A _ 2 …\ldots ANA _ N

Output

Output the answer.

6 10
6 8 2 2 6 4
2

For example, AA can be divided into four contiguous subsequences as (6),(8,2),(2),(6,4)(6),(8,2),(2),(6,4). The sums of the elements of the second and fourth sequences are multiples of 1010, so the score of ((6),(8,2),(2),(6,4))((6),(8,2),(2),(6,4)) is 22.

AA cannot be divided so that the score is 33 or more, so output 2.

8 1
0 0 0 0 0 0 0 0
8
30 8
5 0 4 2 7 3 2 3 2 4 0 1 4 0 4 1 7 5 2 5 0 3 6 6 2 3 2 2 4 2
8

ABC473 赛后模拟赛 ✅

未参加
状态
已结束
规则
IOI
题目
7
开始于
2026-8-29 21:40
结束于
2026-9-12 21:40
持续时间
336 小时
主持人
参赛人数
45