[题目]F. Group Projects [题意]给定k和n个数字ai,要求分成若干集合使得每个集合内部极差的总和不超过k的方案数.n<=200,m<=1000,1<=ai<=500. [算法]动态规划 [题解]每个集合的最小值和最大值非常重要,将序列从小到大排序后,每个集合可以视为最小值到最大值的一条线段. 设$f[i][j][k]$表示前i个数,当前有j条线段没有结束,总和为k的方案数. 转移的关键在于集合权值的拆分,转化为算每个数的贡献.数字a[i+1]的贡献就是覆盖的线段…
F. Group Projects   There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent pieces, and then discuss the results together. It takes the i-th stu…
F. Group Projects 题目连接: http://www.codeforces.com/contest/626/problem/F Description There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent piec…
F - Group Projects 题目大意:给你n个物品, 每个物品有个权值ai, 把它们分成若干组, 总消耗为每组里的最大值减最小值之和. 问你一共有多少种分组方法. 思路:感觉刚看到的时候的想法是先排好序, dp[ i ][ j ][ k ]表示已经划分了 i 个, 并且分成了 j 组, 目前为止的总消耗为k的方案总数. 但是这个状态没有办法转移, 题解提供了一种将贡献分段的方法, 比如说原数组为1 2 3 6 7 8 10, 其中一组里面有 1 3 7 8 那么我们不是 直接计算出(8…
F. Group Projects time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output There are n students in a class working on group projects. The students will divide into groups (some students may be in g…
[CF626F]Group Projects 题目大意: 有一个长度为\(n(n\le200)\)的数列\(\{A_i\}\),将其划分成若干个子集,每个子集贡献为子集\(\max-\min\).求子集贡献和\(\le m(m\le1000)\)的划分方案数. 思路: 将每个数看成数轴上的点,原题中的子集贡献和就是在这些点中,每个点作为至多一个线段的端点,所有线段长度之和(同一线段的两个端点可以相同). 考虑动态规划,将\(\{A_i\}\)排序,用\(f[i][j][k]\)表示用了前\(i\…
Group Projects Description There are n students in a class working on group projects. The students will divide into groups (some students may be in groups alone), work on their independent pieces, and then discuss the results together. It takes the i…
\(>Codeforces\space959 F. Mahmoud\ and\ Ehab\ and\ yet\ another\ xor\ task<\) 题目大意 : 给出一个长度为 \(n\) 序列 \(A\),和 \(q\) 次询问,对于每一次询问给出两个数 \(l, x\) ,你需要计算在前缀和 \(A[1, l]\) 中选取若干个数,使得它们 \(xor\) 起来的结果等于 \(x\) 的方案数 $n , q \leq 10^5   0 \leq A_i \leq 2^{20} $…
\(>Codeforces\space835 F. Roads in the Kingdom<\) 题目大意 : 给你一棵 \(n\) 个点构成的树基环树,你需要删掉一条环边,使其变成一颗树,并最小化删掉环边后的树的直径. \(n \leq 2 \times 10^5\) 树的边权 $ \leq 10^9 $ 解题思路 : 考虑最终树的直径可能由两部分组成,答案是其中的最大值 第一种就是外向树内的直径的最大值,这个只需要随便\(dp\)一下即可,这里不过多讨论 第二种情况树的直径经过原来的环,…
Codeforces 731 F. Video Cards 题目大意:给一组数,从中选一个数作lead,要求其他所有数减少为其倍数,再求和.问所求和的最大值. 思路:统计每个数字出现的个数,再做前缀和,用于之后快速求和.将原数组排序后去重,枚举每一个数做lead的情况下,其余数减少后再求和的结果.不断维护最大值即可. PS:这里用到了一个方便的函数unique()来去重,使用前需要先将数组排序,参数为数组的首地址和尾后地址,返回新的尾后地址.(该函数没有将重复的元素删除,只是放到了尾地址后面)可…