1634: [Usaco2007 Jan]Protecting the Flowers 护花
2014-05-31 12:10
411 查看
#include<algorithm> #include<iostream> #include<cstdio> using namespace std; struct data{int x,y;}a[100001]; inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x*=10;x+=ch-'0';ch=getchar();} return x*f; } inline bool cmp(data a,data b){return a.x*b.y<b.x*a.y;} int n; long long ans,t; int main(){ n=read(); for(int i=1;i<=n;i++){ a[i].x=read();a[i].y=read(); } sort(a+1,a+n+1,cmp); for(int i=1;i<=n;i++){ ans+=t*a[i].y; t+=a[i].x*2; } printf("%lld",ans); return 0; }
相关文章推荐
- 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 护花(贪心)
- BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- bzoj 1634: [Usaco2007 Jan]Protecting the Flowers 护花【贪心】
- 1634: [Usaco2007 Jan]Protecting the Flowers 护花
- [BZOJ1634] [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 护花
- [BZOJ1634][Usaco2007 Jan]Protecting the Flowers 护花 贪心
- 【bzoj1634】[Usaco2007 Jan]Protecting the Flowers 护花 贪心
- |BZOJ 1634|贪心|[Usaco2007 Jan]Protecting the Flowers 护花
- 1634: [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 护花( 贪心 )
- BZOJ1634: [Usaco2007 Jan]Protecting the Flowers 护花