题意:有 n 个学生站成一排,每个学生有一个能力值,牛牛想从这 n 个学生中按照顺序选取 k 名学生,要求相邻两个学生的位置编号的差不超过 d,使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? 思路:表示在i个位置选了j人的最大乘积,表示在i个位置选了j人的最小乘积.为什么要记录最小乘积?因为每个学生的能力值可能为正可能为负,那么必须保存最小乘积,才能保证不遗漏负数相乘的情况. AC代码 #include <stdio.h> #include <algorithm> u…
Maximum sum Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 33918 Accepted: 10504 Description Given a set of n integers: A={a1, a2,..., an}, we define a function d(A) as below: Your task is to calculate d(A). Input The input consists o…