题目传送门

 /*
贪心:按照能选的个数和点数降序排序,当条件不符合就break,水题啊!
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
struct Card
{
int a, b;
}card[MAXN]; bool cmp(Card x, Card y)
{
if (x.b == y.b) return x.a > y.a;
return x.b > y.b;
} int main(void) //Codeforces Round #109 (Div. 2) B. Combination
{
// freopen ("B.in", "r", stdin); int n;
while (scanf ("%d", &n) == )
{
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &card[i].a, &card[i].b);
}
sort (card+, card++n, cmp); int ans = ; int res = ; int cnt = ;
for (int i=; i<=n; ++i)
{
res += card[i].b - ; ans += card[i].a;
cnt = cnt - + card[i].b;
if (cnt <= ) break;
if (res <= ) break;
} printf ("%d\n", ans);
} return ;
}

贪心 Codeforces Round #109 (Div. 2) B. Combination的更多相关文章

  1. 贪心 Codeforces Round #301 (Div. 2) A. Combination Lock

    题目传送门 /* 贪心水题:累加到目标数字的距离,两头找取最小值 */ #include <cstdio> #include <iostream> #include <a ...

  2. 贪心 Codeforces Round #288 (Div. 2) B. Anton and currency you all know

    题目传送门 /* 题意:从前面找一个数字和末尾数字调换使得变成偶数且为最大 贪心:考虑两种情况:1. 有偶数且比末尾数字大(flag标记):2. 有偶数但都比末尾数字小(x位置标记) 仿照别人写的,再 ...

  3. 贪心 Codeforces Round #301 (Div. 2) B. School Marks

    题目传送门 /* 贪心:首先要注意,y是中位数的要求:先把其他的都设置为1,那么最多有(n-1)/2个比y小的,cnt记录比y小的个数 num1是输出的1的个数,numy是除此之外的数都为y,此时的n ...

  4. 贪心 Codeforces Round #297 (Div. 2) C. Ilya and Sticks

    题目传送门 /* 题意:给n个棍子,组成的矩形面积和最大,每根棍子可以-1 贪心:排序后,相邻的进行比较,若可以读入x[p++],然后两两相乘相加就可以了 */ #include <cstdio ...

  5. 贪心 Codeforces Round #304 (Div. 2) B. Soldier and Badges

    题目传送门 /* 题意:问最少增加多少值使变成递增序列 贪心:排序后,每一个值改为前一个值+1,有可能a[i-1] = a[i] + 1,所以要 >= */ #include <cstdi ...

  6. 贪心 Codeforces Round #303 (Div. 2) B. Equidistant String

    题目传送门 /* 题意:找到一个字符串p,使得它和s,t的不同的总个数相同 贪心:假设p与s相同,奇偶变换赋值,当是偶数,则有答案 */ #include <cstdio> #includ ...

  7. 找规律/贪心 Codeforces Round #310 (Div. 2) A. Case of the Zeros and Ones

    题目传送门 /* 找规律/贪心:ans = n - 01匹配的总数,水 */ #include <cstdio> #include <iostream> #include &l ...

  8. 字符串处理/贪心 Codeforces Round #307 (Div. 2) B. ZgukistringZ

    题目传送门 /* 题意:任意排列第一个字符串,使得有最多的不覆盖a/b字符串出现 字符串处理/贪心:暴力找到最大能不覆盖的a字符串,然后在b字符串中动态得出最优解 恶心死我了,我最初想输出最多的a,再 ...

  9. 贪心 Codeforces Round #173 (Div. 2) B. Painting Eggs

    题目传送门 /* 题意:给出一种方案使得abs (A - G) <= 500,否则输出-1 贪心:每次选取使他们相差最小的,然而并没有-1:) */ #include <cstdio> ...

随机推荐

  1. Teamviewer ubuntu 提示 TeamViewer Daemon is not running

    http://blog.csdn.net/laohuang1122/article/details/12657343 Ubunut 12.04下面安装了Teamviewer,刚安装完启动是没有问题的, ...

  2. SQL 主机

    SQL 主机 SQL 主机 如果您想要您的网站存储数据在数据库并从数据库显示数据,您的 Web 服务器必须能使用 SQL 语言访问数据库系统. 如果您的 Web 服务器托管在互联网服务提供商(ISP, ...

  3. Java基础实例

    打印等腰三角形代码 public class ForForTest{ public static void main(String []args){ for(int x=0;x<5;x++){ ...

  4. 关于disable和readonly

    我们在做网页时,难免的会因为权限或者各种原因,想让使用者看到,但是却不想让用户去对值进行更改,我们有两个选择 一.我们使用disabled将文本框禁用掉. 二.我们使用readonly使得文本框只能读 ...

  5. 获取Windows用户所有的账户名

    /// <summary> /// 设置用户密码 /// </summary> [DllImport("Netapi32.dll")] extern sta ...

  6. React Native入门——布局实践:开发京东client首页(一)

    有了一些对React Native开发的简单了解,让我们从实战出发.一起来构建一个简单的京东client. 这个client是仿照之前版本号的京东client开发的Android版应用,来源于CSDN ...

  7. HDU 3469 Catching the Thief (博弈 + DP递推)

    Catching the Thief Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  8. The type java.lang.reflect.AnnotatedElement cannot be resolved. It is indirectly referenced from required .class files

    我这个错误发生于导入项目的时候..我发现主要是jdk版本的问题.切换一下jdk.直接红叉消失就可以了.....jdk版本一致性还是很重要的

  9. myeclipse.hbm.xml自动生成

    第一,你的项目是否搭建了hibernate框架? 第二,你是否建立了相应的数据表: 第三,做好前两步,你再把myeclipse和数据库连接起来,在相应的表上点击右键,生成hibernate 关联文件就 ...

  10. JAVA泛型类

    泛型是JDK 5.0后出现新概念,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数.这种参数类型可以用在类.接口和方法的创建中,分别称为泛型类.泛型接口.泛型方法. 泛型类引入的好处不 ...