Shoemaker's Problem
来源:互联网 发布:php编程 第三版 pdf 编辑:程序博客网 时间:2024/06/06 14:10
http://www.bnuoj.com/bnuoj/problem_show.php?pid=18444
Shoemaker's Problem
64-bit integer IO format: %lld Java class name: Main
[PDF Link]
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 job. For each day of delay before starting to work for the ith job, shoemaker must pay a fine of Si (1<=Si<=10000) cents. Your task is to help the shoemaker, writing a programm to find the sequence of jobs with minimal total fine.
The Input
The input begins with a single positive integer on a line by itself indicating the number of the cases following, each of them as described below. This line is followed by a blank line, and there is also a blank line between two consecutive inputs.First line of input contains an integer N (1<=N<=1000). The next N lines each contain two numbers: the time and fine of each task in order.
The Output
For each test case, the output must follow the description below. The outputs of two consecutive cases will be separated by a blank line.You programm should print the sequence of jobs with minimal fine. Each job should be represented by its number in input. All integers should be placed on only one output line and separated by one space. If multiple solutions are possible, print the first lexicographically.
Sample Input
143 41 10002 25 5
Sample Output
2 1 3 4
#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;struct node{ int nu; int a,b; double su;};bool cmp(node a, node b){ if(a.su==b.su) { return a.nu<b.nu; } return a.su>b.su;}int main(){ int t,n,i; node k[1001]; scanf("%d",&t); while(t--) { scanf("%d",&n); for(i = 0; i < n; i++) { k[i].nu = i+1; scanf("%d%d",&k[i].a,&k[i].b); k[i].su = (double)k[i].b/k[i].a; } sort(k,k+n,cmp); printf("%d",k[0].nu); for(i = 1; i < n; i++) { printf(" %d",k[i].nu); } printf("\n"); if(t!=0) { printf("\n"); } } return 0;}
- Shoemaker's Problem
- 10026 - Shoemaker's Problem
- UVa10026 - Shoemaker's Problem
- 10026 - Shoemaker's Problem
- uva10026 - Shoemaker's Problem
- UVaOJ10026 - Shoemaker's Problem
- Shoemaker's Problem
- Shoemaker's Problem
- 110405 Shoemaker's Problem
- UVA Shoemaker's Problem
- 10026 - Shoemaker's Problem
- uva10026 - Shoemaker's Problem
- UVa 10026 - Shoemaker's Problem
- uva 10026 - Shoemaker's Problem
- uva 10026 - Shoemaker's Problem
- uva 10026 - Shoemaker's Problem
- uva 10026 Shoemaker's Problem
- UVa 10026 - Shoemaker's Problem
- php memory_limit
- 哈希表
- DXUT11框架浅析(6)--功能函数
- Linux 的多线程编程的高效开发经验
- Hibernate+Spring+Struts扩展Struts
- Shoemaker's Problem
- oracle学习(1)----oracle入门、安装配置
- { 数学 }hdoj1568
- DeDecms 获取顶级栏目
- OCP-1Z0-051-V9.02-120题
- 改善C++ 程序的150个建议学习之建议21:尽量用new/delete代替malloc/free
- VM ubuntu磁盘扩容
- Codeforce 214A Old Peykan
- jquery获取子节点和父节点的示例代码