hdu1789 Doing Homework again(贪心+排序)】的更多相关文章

Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18294    Accepted Submission(s): 10648 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he…
题目链接:https://cn.vjudge.net/problem/HDU-1789 题意 小明有一大堆作业没写,且做一个作业就要花一天时间 给出所有作业的时间限制,和不写作业后要扣的分数 问如何安排作业,使被扣分最少 思路 因为有日期这个规定,所以可以提前写作业 有一个思路,复杂度是O(n^2) 就是先算得n天内的最小扣分的安排,然后在n+1天时用第n+1天期限的作业更新一边最小扣分安排 考虑时间1000ms规模1000个数据,O(n^2)太冒险,所以考虑贪心 贪心思路O(n) 为了让扣分最…
题目链接:https://vjudge.net/problem/HDU-1789 题目大意: 给出N个作业的截至日期,和N个作业不交所扣掉的分数,要求输出扣除分数做少的方案. 解析: 与上一道销售商品类似,将分数从大到小排序,找到deadline,如果它的期限没有被占用,就在该天写完,然后vis置1,如果占用,则从它的前一天开始向前查找有没有空闲的日期,如果有则占用,vis置1.这样就可以得到最大分数.然后用总分数减去得到最大分数即为扣除的最小分数. #include <cstdio> #in…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6878    Accepted Submission(s): 4096 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he h…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1789 题目大意: 给出N个作业的截至日期,和N个作业不交所扣掉的分数,要求输出扣除分数做少的方案. 思路: 贪心, 正确的策略是: 扣除分数大的先做 扣除分数相同,先截止的先做 做一件事的时候,从截止时间开始向第一天遍历,如果当天没有被作业占据则标记为占据.做这件事的日期越大越好. 如果不能满足3的条件,则为不能完成 #include<iostream> #include<cstdio&g…
Doing Homework again 这只是一道简单的贪心,但想不到的话,真的好难,我就想不到,最后还是看的题解 [题目链接]Doing Homework again [题目类型]贪心 &题意: Ignatius有N项作业要完成.每项作业都有限期,如果不在限期内完成作业,期末考就会被扣相应的分数.给出测试数据T表示测试数,每个测试以N开始(N为0时结束),接下来一行有N个数据,分别是作业的限期,再有一行也有N个数据,分别是若不完成次作业会在期末时被扣的分数.求出他最佳的作业顺序后被扣的最小的…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 13847    Accepted Submission(s): 8036 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he h…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem DescriptionIgnatius has just come back school from the 30th ACM/ICPC. Now he has a lot of homework to do. Eve…
Doing Homework again 点我挑战题目 题意分析 给出n组数据,每组数据中有每份作业的deadline和score,如果不能按期完成,则要扣相应score,求每组数据最少扣除的score是多少. 典型的贪心策略. 既然是要求最少的扣分,那么肯定是要先完成分数最多的.所以可以推出按照分数排序.那么最佳策略应该是在deadline当天完成作业,如果那天已经占用,只能在deadline-1天完成,如果那天也被占用了,就只能在deadline-2天完成--直到推到第1天,如果还被占用的话…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10705    Accepted Submission(s): 6299 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he h…