Jilin University ACM Training Team Trial (Replay) Question B

The meaning of the question: a sequence to find a set, the sum is the largest and can be divisible by 5.
Idea: The question of dp selection and non-election.
opt[i][j] means choose any one of the first i items, sum%5=the maximum value of j.
1. Without selecting the i-th number, the optimal solution of the current remainder j is the optimal solution of the previous state remainder j.
2. Choose the i-th number, then the optimal solution of the current remainder j is required, and the remainder x of the previous state must satisfy
(a[i]+opt[i-1][x])%5==j

Guess you like

Origin blog.csdn.net/weixin_43916777/article/details/106840739