F. Zero Remainder Sum---Codeforces Round #677 (Div. 3)--题解

这篇博客介绍了Codeforces Round #677 (Div. 3)中的一道题目——F. Zero Remainder Sum。内容包括如何在限制条件下选择矩阵元素,使每行不超过一半元素的和能被k整除,并求出最大这样的和。博主通过观察样例和直觉发现了一种规律,并验证了其正确性。
摘要由CSDN通过智能技术生成

F. Zero Remainder

F. Zero Remainder Sum

You are given a matrix a of size n×m consisting of integers.

You can choose no more than ⌊m2⌋ 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).

Input
The first line of the input contains three integers n, m and k (1≤n,m,k≤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 ai,j (1≤ai,j≤70).

Output
Print one integer — the maximum sum divisible by k you can obtain.

Examples
inputCopy
3 4 3
1 2 3 4
5 2 2 2
7

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值