/* * 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…
题意:鞋匠一口气接到了不少生意,但是做鞋需要时间,鞋匠只能一双一双地做,根据协议每笔生意如果拖延了要罚钱. 给出每笔生意需要的天数和每天的罚钱数,求出最小罚钱的排列顺序. 只要按罚款/天数去从大到小排序,如果比例一样就按序号排序(要求字典序). 解释我就不献丑了,附上Staginner大神的证明: 对于为什么贪心策略是这个样子的,我们不妨拿相邻的两个事件a.b来说明一下.由于a.b之后的事件是固定的,所以我们无论排成ab还是排成ba后面部分的损失都是固定的,那么损失的差别主要来源于究竟是排成ab…
题目连接:10026 Shoemaker's Problem 题目大意:有一个鞋匠接了n双要修的鞋子, 修每双鞋需要d天,每推迟一天修将亏损val元,问按什么样的顺序修鞋可以保证损失最少,如果有多种情况输出字典序最小的. 解题思路:最开始把损失钱数最大的放在前面,后来发现每层子问题是相互有影响的,所以不能从整体的损失来看,所以后来改成对两个鞋的装态比较,只要考虑哪双鞋放前和哪双鞋放后就可以了. #include <stdio.h> #include <string.h> #incl…
题意:鞋匠现在有n个工作要做,每个工作要x天,没延迟一天需要付款y,鞋匠每天只能做一个工作,问使得鞋匠最少赔款的工作顺序. 思路:工作和工作之间排序,如果a.value*b.day>b.value*a.day  a工作应该排在前面 #include <iostream> #include<cstdio> #include<algorithm> using namespace std; #define N 1010 struct node{ int day; int…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=967 对价钱与天数比例排序,贪心即可. #include <cstdio> #include <cstring> #include <algorithm> #define maxn 2000 using namespace std; int n; struc…
/* * URAL_1014.cpp * * Created on: 2013年10月11日 * Author: Administrator */ #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; const int maxn = 11; int a[maxn]; int main() { int n; scanf(…
Shoemaker's Problem Shoemaker has N jobs (orders from customers) which he must make. Shoemaker can work on only one job in each day. For each ith job, it is known the integer Ti (1<=Ti<=1000), the time in days it takes the shoemaker to finish the jo…
English appre: an infinite straight line:一条无限长的直线 on the coasting:在海岸线上 Cartesian coordinate system, 题目地址:http://poj.org/problem?id=1328 我的代码: #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algori…
UVa 101 The Blocks Problem 一道纯模拟题 The Problem The problem is to parse a series of commands that instruct a robot arm in how to manipulate blocks that lie on a flat table. Initially there are nblocks on the table (numbered from 0 to n-1) with block bi…
 UVa 1380 A Scheduling Problem 题目: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=41557 思路:   给出一个任务调度树,单向边u->v表示u必须在v之前完成,双向边u-v表示无所谓方向. 题目给出定理,首先dfs求得忽略无向边后的最长链点数k,那么问题就是判断是否可以通过无向边定向从而使得最长链点数不超过k.用dp的判断. 设f[i]表示以i为根的子树中所有的边定向后最长链点数不超过…