poj 3262
来源:互联网 发布:淘宝天猫内部券代理 编辑:程序博客网 时间:2024/06/04 18:36
<span style="font-size:18px;">这道题根据D/T先排序的思想确实没想到,看了别人的代码才写的,基本上也不算是自己写的了!!看来数学还是学的不好啊!</span>
#include<stdio.h>#include<stdlib.h>#include<algorithm>using namespace std;#define M 100050struct ff{ int t, p;};long long sumt,sum;int cmp(ff a, ff b){ return 1.0*a.p/a.t>1.0*b.p/b.t;}ff f[M];int main(){ int n, i; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d %d", &f[i].t, &f[i].p); } sort(f,f+n,cmp); //for(i=0;i<n;i++) //printf("%d %d\n",f[i].t,f[i].p); sumt=2*f[0].t; //printf("%lld\n",sumt); sum=0; for(i=1;i<n;i++) { sum=sum+sumt*f[i].p; sumt=sumt+f[i].t*2; } printf("%lld\n", sum); system("pause"); return 0;}
0 0
- poj 3262
- poj 3262
- 【POJ】3262
- POJ 3262
- poj 3262 贪心
- poj 3262贪心
- poj 3262 比例贪心
- POJ 3262 贪心
- poj 3262 贪心比率
- 贪心 POJ 3262
- POJ 3262 (贪心)
- poj 3262 贪心
- POJ
- poj
- POJ
- POJ
- poj
- poj
- 第26讲
- phoneGap-Android开发环境搭建
- 健康养生 清晨四个要,晚上五个不
- 第27讲
- Oracle中的存储过程
- poj 3262
- 第28讲
- Tomcat相关配置
- 2-SAT题集
- 第29讲
- lua源码剖析1【转】
- 第30讲
- lua源码剖析2【转】
- 深入解析java虚拟机-jvm运行机制