BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花
来源:互联网 发布:php虚拟主机 编辑:程序博客网 时间:2024/05/16 15:16
贪心
因为交换这俩头牛的搬走顺序不会影响其他牛
所以只要排序就好了
下面的
当
因为赶走牛
所以应该尽快赶走牛
#include<set>#include<map>#include<cmath>#include<ctime>#include<queue>#include<stack>#include<cstdio>#include<vector>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>#define g getchar()#define ll long long#define inf 0x3f3f3f3fusing namespace std;inline ll read(){ ll x=0,f=1;char ch=g; for(;ch<'0'||ch>'9';ch=g)if(ch=='-')f=-1; for(;ch>='0'&&ch<='9';ch=g)x=x*10+ch-'0'; return x*f;}inline void out(ll x){ int a[25],wei=0; if(x<0)putchar('-'),x=-x; for(;x;x/=10)a[++wei]=x%10; if(wei==0){puts("0");return;} for(int j=wei;j>=1;--j)putchar('0'+a[j]); putchar('\n');}struct re{int x,y;}d[100001];int n;ll ans,t;bool cmp(re x,re y){ return x.x*y.y>y.x*x.y;}int main(){// freopen("","r",stdin);// freopen("","w",stdout); n=read(); for(int i=1;i<=n;++i) d[i].y=read(),d[i].x=read(); sort(d+1,d+1+n,cmp); ans=0;t=0; for(int i=1;i<=n;++i) ans+=t*d[i].x,t+=d[i].y*2; out(ans); return 0;}
0 0
- BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- BZOJ 1634 [Usaco2007 Jan]Protecting the Flowers 护花
- |BZOJ 1634|贪心|[Usaco2007 Jan]Protecting the Flowers 护花
- bzoj 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- BZOJ [Usaco2007 Jan]Protecting the Flowers 护花(隐藏题)
- [BZOJ1634] [Usaco2007 Jan]Protecting the Flowers 护花
- bzoj1634[Usaco2007 Jan]Protecting the Flowers 护花
- BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花
- bzoj 1634: [Usaco2007 Jan]Protecting the Flowers 护花(贪心排序)
- 【USACO】2007 Jan Protecting the Flowers 保护花朵
- Protecting the Flowers(3262)
- POJ3262-Protecting the Flowers
- [Usaco07Jan] Protecting the Flowers
- [POJ3262]Protecting the Flowers
- POJ Protecting the Flowers
- 扩大VMware虚拟机中linux硬盘空间
- HealthKit框架的简要与基本使用(OC版)
- dubbo相关知识(一)
- 机器学习中的范数规则化之 L0、L1与L2范数
- Redis配置文件redis.conf 详解
- BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- 【PHP设计模式】——单例模式
- 转来学习ActionBar
- java cmd命令行初识helloworld
- iOS TableView给力动画的简单实现
- Android中MediaRecorder类实现视频的录制
- java concurrent包介绍及使用
- Trie树
- android imageview 图片不能正常显示 或不能自适应的解决方法