P2878 [USACO07JAN]保护花朵Protecting the Flowers
一个类似国王游戏的贪心
话说要是先做了这个题,国王游戏之余懵逼这么久吗?
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node
{
long long t;
long long d;
};
node data[101000];
bool compare(const node &a,const node &b)
{
return a.d*b.t>b.d*a.t;
}
int main()
{
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++)
scanf("%d%d",&data[i].t,&data[i].d);
sort(data+1,data+1+n,compare);
long long sum=0;
long long tim=0;
for(int i=1;i<=n;i++)
{
sum+=data[i].d*=tim;//牛都吓傻了
tim+=data[i].t*2;
}
printf("%lld",sum);
}
P2878 [USACO07JAN]保护花朵Protecting the Flowers的更多相关文章
- bzoj1634 / P2878 [USACO07JAN]保护花朵Protecting the Flowers
P2878 [USACO07JAN]保护花朵Protecting the Flowers 难得的信息课......来一题水题吧. 经典贪心题 我们发现,交换两头奶牛的解决顺序,对其他奶牛所产生的贡献并 ...
- 洛谷——P2878 [USACO07JAN]保护花朵Protecting the Flowers
P2878 [USACO07JAN]保护花朵Protecting the Flowers 题目描述 Farmer John went to cut some wood and left N (2 ≤ ...
- 洛谷P2878 [USACO07JAN]保护花朵Protecting the Flowers
题目描述 Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. ...
- Luogu_2878_[USACO07JAN]保护花朵Protecting the Flowers
题目描述 Farmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. ...
- USACO 保护花朵 Protecting the Flowers, 2007 Jan
Description 约翰留下了 N 只奶牛呆在家里,自顾自地去干活了,这是非常失策的.他还在的时候,奶牛像 往常一样悠闲地在牧场里吃草.可是当他回来的时候,他看到了一幕惨剧:他的奶牛跑进了他的花园 ...
- USACO Protecting the Flowers
洛谷 P2878 [USACO07JAN]保护花朵Protecting the Flowers 洛谷传送门 JDOJ 1009: 护花 JDOJ传送门 Description FJ出去砍木材去了,把N ...
- BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 448 So ...
- BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花( 贪心 )
考虑相邻的两头奶牛 a , b , 我们发现它们顺序交换并不会影响到其他的 , 所以我们可以直接按照这个进行排序 ------------------------------------------- ...
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 493 So ...
随机推荐
- 在Mac上安装mysql
进入这个网站: https://dev.mysql.com/downloads/mysql/ 然后点击安装就行了. 注意在这里启动mysql 然后mac上所有的mysql命令都得用绝对路径才能生效
- protobuf在c++的使用方法以及在linux安装
https://blog.csdn.net/wangyin668/article/details/80046798 https://www.cnblogs.com/zhouyang209117/p ...
- linux终端没有GUI时python使用matplotlib如何画图
import matplotlib as mpl mpl.use('Agg') #而且必须添加在import matplotlib.pyplot之前,否则无效 ======== ======== == ...
- python groupby的小技巧
df.groupby('col',as_index=False),agg(ufunk)#as_index=False,可以消除层次索引 更多grouby的用法 http://blog.csdn.net ...
- Murano Weekly Meeting 2016.08.02
Meeting time: 2016.August.02 1:00~2:00 Chairperson: Valerii Kovalchuk, from Mirantis Meeting summar ...
- [原创]hibernate更新后jdbc读取不到数据问题
最近在做工作流插件时使用的是自己基于hibernate连接封装的orm框架,按说跟hibernate共用的一个连接,应该在同一个事务中,但在使用时hibernate saveOrUpdate后(未提交 ...
- 020-pom.xml配置文件模板
1 Maven 整合SSH框架之pom.xml 1 版本一 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns: ...
- DEDE图集手工上传图片,加入水印
DEDE的图集手工上传图片,是一个非常好用的flash上传图片工具.但是如果我们希望上传的图片,带有自己网站指定的水印,却发现没有达到我们的要求--那么如果我们确实希望上传的图片,带有水印,怎么办?以 ...
- python 字符串转字节数组
场景: java加解密和python加解密互转的时候,因一些非显示字符无法确认两者是否一致,故需要打出他们的十六进制字节数组进行比较 1.python代码实现 str='123';print str. ...
- #与javascript:void(0)的区别
#"包含了一个位置信息 默认的锚点是#top 也就是网页的上端 而javascript:void(0) 仅仅表示一个死链接 这就是为什么有的时候页面很长浏览链接明明是#可是跳动到了页首 而 ...