(贪心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 ...
随机推荐
- easyui toolbar 可以放在datagrid底下
html: <div class="easyui-tabs" style="height: 250px;" tools="#t_rank&quo ...
- Java 执行 SQL 脚本文件
转自:http://blog.csdn.net/hongmin118/article/details/4588941 package com.unmi.db; import java.io.FileI ...
- Thinking in life(1)
There is always one things we donot notice---time ,which is the most important to all of us.By watch ...
- mvc异步表单遇到的问题
1,mvc异步表单遇到的问题 问题:使用jqury easy ui 时提交异步数据不能请求到服务器 解决办法:经过细心调试和检测,发现jqury的加载顺序放在了easy ui之后,所以首先加 ...
- c# 应用程序部署发布
转自:http://blog.csdn.net/chenyujing1234/article/details/7558185 最近做了C#软件,发布给客户用时,发现客户运行不起来,原因是客户电脑上没有 ...
- 2463: [中山市选2009]谁能赢呢?- BZOJ
Description小明和小红经常玩一个博弈游戏.给定一个n×n的棋盘,一个石头被放在棋盘的左上角.他们轮流移动石头.每一回合,选手只能把石头向上,下,左,右四个方向移动一格,并且要求移动到的格子之 ...
- Java---算法---插入排序
/** * 插入排序(升序) * * @param array */ public static void insertSort(int[] array) { int j = 0; // 下标从1开始 ...
- 剑指offer--面试题15--相关
感受:清晰的思路是最重要的!!! 题目:求链表中间节点 ListNode* MidNodeInList(ListNode* pHead) { if(pHead == NULL) return NULL ...
- redis 资料链接
redis 资料链接 http://blog.nosqlfan.com/html/3537.html
- Unity3D脚本中文系列教程(十四)
http://dong2008hong.blog.163.com/blog/static/469688272014032134394/ WWWFrom 类Unity3D脚本中文系列教程(十三)辅助类. ...