博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 1789 Doing Homework again
阅读量:4538 次
发布时间:2019-06-08

本文共 2307 字,大约阅读时间需要 7 分钟。

Doing Homework again

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 10008    Accepted Submission(s): 5854

Problem Description
Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Every teacher gives him a deadline of handing in the homework. If Ignatius hands in the homework after the deadline, the teacher will reduce his score of the final test. And now we assume that doing everyone homework always takes one day. So Ignatius wants you to help him to arrange the order of doing homework to minimize the reduced score.
 

 

Input
The input contains several test cases. The first line of the input is a single integer T that is the number of test cases. T test cases follow.
Each test case start with a positive integer N(1<=N<=1000) which indicate the number of homework.. Then 2 lines follow. The first line contains N integers that indicate the deadlines of the subjects, and the next line contains N integers that indicate the reduced scores.
 

 

Output
For each test case, you should output the smallest total reduced score, one line per test case.
 

 

Sample Input
3 3 3 3 3 10 5 1 3 1 3 1 6 2 3 7 1 4 6 4 2 4 3 3 2 1 7 6 5 4
 

 

Sample Output
0 3 5
 

 

Author
lcy
 

 

Source
 

 

Recommend
lcy
 
 
对于每个作业,先按照扣分从大到小排序,若分数相同则按照截止日期从小到大排序。
然后按顺序,从截止日期开始往前找没有占用掉的时间。
如果找不到了,则加到罚分里面。
 
 
1 #include 
2 #include
3 #include
4 using namespace std; 5 6 const int MAX = 1050; 7 struct Homework 8 { 9 int s;10 int d;11 };12 typedef Homework H;13 H h[MAX];14 bool u[MAX];15 bool compare(const H& h1, const H& h2)16 {17 if (h1.s>h2.s)18 return true;19 else if (h1.s == h2.s && h1.d
0; j--)31 {32 if (!u[j])33 {34 u[j] = true;35 break;36 }37 }38 if (j == 0)39 score += h[i].s;40 }41 return score;42 }43 int main()44 {45 int t, n, pos;46 scanf("%d", &t);47 while (t--)48 {49 scanf("%d", &n);50 memset(u, 0, sizeof(u));51 for (int i = 0; i < n; i++)52 scanf("%d", &h[i].d);53 54 for (int i = 0; i

 

 
 

转载于:https://www.cnblogs.com/cumulonimbus/p/5158731.html

你可能感兴趣的文章
Kafka Producer相关代码分析【转】
查看>>
麻省理工学院公开课-第四讲:快速排序 及 随机化 算法
查看>>
pycharm 的包路径设置export PYTHONPATH=$PYTHONPATH
查看>>
SQL语句创建函数
查看>>
解决mysql无法显示中文/MySQL中文乱码问号等问题
查看>>
CentOS 7.2 配置mysql5.7
查看>>
python输出转义字符
查看>>
计算一个整数二进制中1的个数
查看>>
netdom join 错误:指定的域不存在,或无法联系。
查看>>
Android中Dialog的使用
查看>>
Android Activity接收Service发送的广播
查看>>
[Leetcode] Spiral Matrix | 把一个2D matrix用螺旋方式打印
查看>>
加速和监控国际网络
查看>>
【Flex】读取本地XML,然后XML数据转成JSON数据
查看>>
字符串循环右移-c语言
查看>>
解决从pl/sql查看oracle的number(19)类型数据为科学计数法的有关问题
查看>>
古训《增广贤文》
查看>>
职场的真相——七句话
查看>>
xcode命令行编译时:codesign命令,抛出“User interaction is not allowed.”异常 的处理...
查看>>
[转载]开机出现A disk read error occurred错误
查看>>