Streets and Avenues in Berhattan 我们首先能发现在最优情况下最多只有一种颜色会分别在行和列, 因为你把式子写出来是个二次函数, 在两端取极值. 然后我们就枚举哪个颜色会分别在行和列. 然后枚举这种颜色在行的个数, 再求出需要在列放的最少的这种颜色的个数. 这个我们可以用dp来check, dp[ i ] 表示 完整地加入若干种颜色能否恰好为 i , 然后再把dp[ i ]转成, 能组成大于等于 i 的最小值. #include<bits/stdc++.h> #d…
题目链接:https://codeforc.es/contest/1070/problem/J 题意:给出一个长度为 k 的字符串,选出 n 个和 m 个不同位置的字符构成两个字符串,使得两个字符串相同字母的对数最少. 题解:在最优解的情况下,两个字符串相同的字母只有一个(假设有两种相同的字母,调换他们的位置变得只有一种相同字母的时候更优,可以自行草稿纸上写下不等式证明),可以枚举相同的字母,剩下的字母做 01 背包判断可以构成的最大长度即可. #include <bits/stdc++.h>…
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de Janeiro holds a tennis tournament and Ostap Bender doesn't want to miss this event. There will be n players participating, and the tournament will fo…
In Pavlopolis University where Noora studies it was decided to hold beauty contest "Miss Pavlopolis University". Let's describe the process of choosing the most beautiful girl in the university in more detail. The contest is held in several stag…