CF888E.Maximum Subsequence
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n integers, and additionally an integer m . You have to choose some sequence of indices b1,b2,...,bk ( 1<=b_{1}<b_{2}<...<b_{k}<=n ) in such a way that the value of is maximized. Chosen sequence can be empty.
Print the maximum possible value of .
输入格式
The first line contains two integers n and m ( 1<=n<=35 , 1<=m<=109 ).
The second line contains n integers a1 , a2 , ..., an ( 1<=ai<=109 ).
输出格式
Print the maximum possible value of .
输入输出样例
输入#1
4 4 5 2 4 1
输出#1
3
输入#2
3 20 199 41 299
输出#2
19
说明/提示
In the first example you can choose a sequence b=1,2 , so the sum is equal to 7 (and that's 3 after taking it modulo 4 ).
In the second example you can choose a sequence b=3 .