A
D:用前面的H去消去后面的K 然后求最长连续的M
F:在每一列/行里面求最大的数然后组成最大的和ans[]里的比求出最大的
L:并查集
J:DP背锅题 01背包 先求出M种里每种的size和last然后先last最大的放在最后 然后背包DP
long long solve(Group* groups) { long long* x = new long long[n + 1]; for (int i=0; i<n+1; i++) x[i] = INFINITY; x[0] = 0; // all groups but the last; the last always goes // into "last" bus for (int i=0; i<m-1; i++) for (int j=n-groups[i].size; j>=0; j--) { long long time = max(x[j], groups[i].time); x[j+groups[i].size] = min(time, x[j+groups[i].size]); } //for (int i=0; i<=n; i++) cout << x[i] << " "; //cout << endl; long long answer = -1; for (int i=0; i<=k; i++) if (n - i <= k) if (x[i] < INFINITY) { long long total = x[i] * i + (n - i) * groups[m-1].time; if (answer == -1 || total < answer) answer = total; } return answer; }
X[i]表示有i人在一个飞机上时的最小last
然后i从0枚举到k如果剩下的不大于K就统计total 更新答案