307910: CF1433F. Zero Remainder Sum
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Zero Remainder Sum
题意翻译
给定$n*m$的矩阵$A$,和一个整数$k$,要求每行只能选取不超过一半的元素,且总的选择元素的和要是k的倍数,求最大值。题目描述
You are given a matrix $ a $ of size $ n \times m $ consisting of integers. You can choose no more than $ \left\lfloor\frac{m}{2}\right\rfloor $ elements in each row. Your task is to choose these elements in such a way that their sum is divisible by $ k $ and this sum is the maximum. In other words, you can choose no more than a half (rounded down) of elements in each row, you have to find the maximum sum of these elements divisible by $ k $ . Note that you can choose zero elements (and the sum of such set is $ 0 $ ).输入输出格式
输入格式
The first line of the input contains three integers $ n $ , $ m $ and $ k $ ( $ 1 \le n, m, k \le 70 $ ) — the number of rows in the matrix, the number of columns in the matrix and the value of $ k $ . The next $ n $ lines contain $ m $ elements each, where the $ j $ -th element of the $ i $ -th row is $ a_{i, j} $ ( $ 1 \le a_{i, j} \le 70 $ ).
输出格式
Print one integer — the maximum sum divisible by $ k $ you can obtain.
输入输出样例
输入样例 #1
3 4 3
1 2 3 4
5 2 2 2
7 1 1 4
输出样例 #1
24
输入样例 #2
5 5 4
1 2 4 2 1
3 5 1 2 4
1 5 7 1 2
3 8 7 1 2
8 4 7 1 6
输出样例 #2
56