(贪心5.2.1)UVA 10026 Shoemaker's Problem(利用数据有序化来进行贪心选择)
/*
* UVA_10026.cpp
*
* Created on: 2013年10月10日
* Author: Administrator
*/ #include <iostream>
#include <cstdio>
#include <algorithm> using namespace std; const int maxn = 1010;
struct job{
double a;
int num;
}p[maxn]; bool cmp(job x, job y){
if(x.a > y.a || (x.a == y.a && x.num < y.num)){
return true;
} return false;
} int main(){
int t;
scanf("%d",&t);
int counter = 1;
while(t--){
int n;
scanf("%d",&n); int i;
for(i = 1 ; i <= n ; ++i){
double a1,a2;
scanf("%lf%lf",&a1,&a2);
p[i].a = a2/a1;
p[i].num = i;
} sort(p+1,p+1+n,cmp); if(counter > 1){
printf("\n");
}
for(i = 1 ; i < n ; ++i){
printf("%d ",p[i].num);
} printf("%d\n",p[n].num); counter++;
} return 0;
}
(贪心5.2.1)UVA 10026 Shoemaker's Problem(利用数据有序化来进行贪心选择)的更多相关文章
- UVA 10026 Shoemaker's Problem 鞋匠的难题 贪心+排序
题意:鞋匠一口气接到了不少生意,但是做鞋需要时间,鞋匠只能一双一双地做,根据协议每笔生意如果拖延了要罚钱. 给出每笔生意需要的天数和每天的罚钱数,求出最小罚钱的排列顺序. 只要按罚款/天数去从大到小排 ...
- uva 10026 Shoemaker's Problem(排序)
题目连接:10026 Shoemaker's Problem 题目大意:有一个鞋匠接了n双要修的鞋子, 修每双鞋需要d天,每推迟一天修将亏损val元,问按什么样的顺序修鞋可以保证损失最少,如果有多种情 ...
- uva 10026 Shoemaker's Problem _贪心
题意:鞋匠现在有n个工作要做,每个工作要x天,没延迟一天需要付款y,鞋匠每天只能做一个工作,问使得鞋匠最少赔款的工作顺序. 思路:工作和工作之间排序,如果a.value*b.day>b.valu ...
- uva 10026 Shoemaker's Problem
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- (贪心5.2.6)URAL 1014 Product of Digits(利用数据有序化进行贪心选择)
/* * URAL_1014.cpp * * Created on: 2013年10月11日 * Author: Administrator */ #include <iostream> ...
- UVA 10026 Shoemaker's Problem
Shoemaker's Problem Shoemaker has N jobs (orders from customers) which he must make. Shoemaker can w ...
- Radar Installation(利用数据有序化进行贪心选择)
English appre: an infinite straight line:一条无限长的直线 on the coasting:在海岸线上 Cartesian coordinate system, ...
- UVa 101 The Blocks Problem Vector基本操作
UVa 101 The Blocks Problem 一道纯模拟题 The Problem The problem is to parse a series of commands that inst ...
- 【暑假】[深入动态规划]UVa 1380 A Scheduling Problem
UVa 1380 A Scheduling Problem 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=41557 ...
随机推荐
- Sqlite: unable to open database file
A database connect, there updated both queries (different statement, and regardless of order), after ...
- 提高Linux上socket性能
在 开发 socket 应用程序时,首要任务通常是确保可靠性并满足一些特定的需求.利用本文中给出的 4 个提示,您就可以从头开始为实现最佳性能来设计并开发 socket 程序.本文内容包括对于 Soc ...
- 自定义的你的ubuntu鼠标右键
首先看下效果图: 好,接下来讲下如何实现,“下一个桌面”和”在终端打开“,首先是安装必要软件 sudo apt-get -y install nautilus-open-terminal nautil ...
- cocos2dx中创建动画的三种方法
1.最最原始的方法,先创建动画帧,再创建动画打包(animation),再创建动画(animate) 第一步: 创建动画帧:CCSpriteFrame,依赖于原始的资源图片(xx.png,xx.jpg ...
- what are Datatypes in SQLite supporting android
As said at Datatypes In SQLite Version 3: Datatypes In SQLite Version 3 Most SQL database engines (e ...
- 如何自定义Liferay 7 portal的Log in登录界面
前提: 1. Liferay portal 7 2. Liferay IDE 3.0.1 Liferay现有的工具中提供了很多修改portal的模板,以满足开发者的各种自定义需求. 修改的原理是利用M ...
- 【经验】Angularjs 中使用 layDate 日期控件
layDate 控件地址:http://laydate.layui.com/ 前情:原来系统中使用的日期控件是UI bootstrap(地址:https://angular-ui.github.io/ ...
- HTML弹出窗口
1.最简单的 <script type="text/javascript"> <!-- window.open("http://cn.bing.com& ...
- 不同的source control下配置DiffMerge
TFS: 1. 打开Option -> Source Control -> Visual Studio TFS -> Configure User Tools; 2. 添加 .*, ...
- 2659: [Beijing wc2012]算不出的算式 - BZOJ
最近有点颓废,刷水题,数学题(根本不会做啊) 题意:求 q,p是两个奇质数 网上题解就直接说是几何意义,问了别人才知道 我们在坐标轴上画出来就是在线段y=(q/p)x下方的格点和y=(p/q)x下方的 ...