#C4411. Split Array Divisible Sums

    ID: 47947 Type: Default 1000ms 256MiB

Split Array Divisible Sums

Split Array Divisible Sums

You are given an array of integers and an integer ( k ). Your task is to determine whether it is possible to split the array into two non-empty contiguous subarrays such that the sum of the elements in both subarrays is divisible by ( k ).

Formally, let the array be ( A = [a_1, a_2, \dots, a_n] ). You need to find an index ( i ) with ( 1 \leq i < n ) such that [ \left(\sum_{j=1}^{i} a_j\right) \bmod k = 0 \quad \text{and} \quad \left(\sum_{j=i+1}^{n} a_j\right) \bmod k = 0. ] If such an index exists, output YES; otherwise, output NO.

inputFormat

The first line contains two integers ( n ) and ( k ) ( (2 \leq n \leq 10^5,\ |k| \geq 1) ) representing the number of elements in the array and the divisor respectively. The second line contains ( n ) space-separated integers representing the elements of the array ( A ).

outputFormat

Output a single line containing YES if there exists an index ( i ) satisfying the conditions; otherwise, output NO.## sample

4 10
5 10 15 20
YES