一个类似国王游戏的贪心


话说要是先做了这个题,国王游戏之余懵逼这么久吗?

#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的更多相关文章

  1. bzoj1634 / P2878 [USACO07JAN]保护花朵Protecting the Flowers

    P2878 [USACO07JAN]保护花朵Protecting the Flowers 难得的信息课......来一题水题吧. 经典贪心题 我们发现,交换两头奶牛的解决顺序,对其他奶牛所产生的贡献并 ...

  2. 洛谷——P2878 [USACO07JAN]保护花朵Protecting the Flowers

    P2878 [USACO07JAN]保护花朵Protecting the Flowers 题目描述 Farmer John went to cut some wood and left N (2 ≤ ...

  3. 洛谷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. ...

  4. 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. ...

  5. USACO 保护花朵 Protecting the Flowers, 2007 Jan

    Description 约翰留下了 N 只奶牛呆在家里,自顾自地去干活了,这是非常失策的.他还在的时候,奶牛像 往常一样悠闲地在牧场里吃草.可是当他回来的时候,他看到了一幕惨剧:他的奶牛跑进了他的花园 ...

  6. USACO Protecting the Flowers

    洛谷 P2878 [USACO07JAN]保护花朵Protecting the Flowers 洛谷传送门 JDOJ 1009: 护花 JDOJ传送门 Description FJ出去砍木材去了,把N ...

  7. BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花

    1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 448  So ...

  8. BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花( 贪心 )

    考虑相邻的两头奶牛 a , b , 我们发现它们顺序交换并不会影响到其他的 , 所以我们可以直接按照这个进行排序 ------------------------------------------- ...

  9. 1634: [Usaco2007 Jan]Protecting the Flowers 护花

    1634: [Usaco2007 Jan]Protecting the Flowers 护花 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 493  So ...

随机推荐

  1. robotFramework接口测试GET和POST请求

    安装: 接口测试需要安装Request和RequestLibrary 包 使用cmd命令安装:pip install requests 使用cmd命令安装:pip install -U robotfr ...

  2. input校验不能以0开头的数字

    不以零开头 <input type="text"  class="form-control"  onkeyup="value=value.rep ...

  3. DedeCMS织梦自定义图片字段调用出现{dede:img ..}

    做站过程中碰到这样一个问题,找到解决办法收藏分享:为什么在首页用自定义列表调用出来的图片字段不是正确的图片地址,而是类似于: {dede:img text='' width='270' height= ...

  4. Http Client 源码分析

    /** * 此接口仅代表HTTP请求执行的最基本约定. * 它对请求执行过程没有任何限制或特定的细节,并将状态管理.身份验证和重定向处理的细节留给单个实现. */ public interface H ...

  5. mysql-增删改(DML)

    插入:insert /*方式一:经典的插入 insert into 表名(列名,...) values(值1,...); */ #.插入的值的类型要与列的类型一致或兼容 INSERT INTO bea ...

  6. maven课程 项目管理利器-maven 3-7 maven依赖范围 2星

    本节主要讲了maven的依赖范围: 在pom.xml   dependency标签的scope中.eclipse中有编译的路径,maven中有编译,运行,测试的路径. 1 scope为test,为测试 ...

  7. oracle基本查询练习

    select * from regions; select * from countries; select * from locations; select * from departments; ...

  8. django orm 多对多自定义第三张表

    # -*- coding: utf-8 -*-# Generated by Django 1.11.11 on 2018-09-02 08:07from __future__ import unico ...

  9. php的yii框架开发总结1

    最近用php的yii框架写了一个小的demo,虽然不复杂,但是也学习了很多东西,现在总结一下. 项目需求:为几个教研室写一个日报系统,每个人每天写日报,并且系统有自动实现发邮件功能. 额外要求:1.人 ...

  10. 基于FPGA的VGA显示设计(二)

    上一篇:基于FPGA的VGA显示设计(一)     参照 CrazyBingo 的 基于FPGA的VGA可移植模块终极设计代码  的工程代码风格,模块化处理了上一篇的代码,并增加了一点其它图形. 顶层 ...