HDU1789Doing Homework again(贪心)】的更多相关文章

HDU1789Doing Homework again(贪心) 题目链接 题目大意:给你n们作业的最后期限和过了这个期限没做须要扣的分数.问如何安排能够使得扣分最少. 解题思路:贪心,将扣分多的作业排在前面,扣分同样的依照最后期限前的排前面,然后用一个数组来表示第i天是否有安排.每次都将第i个作业放到它的最后期限的那天完毕,但假设这一天被占了,那么就仅仅能往前移动,找空暇的天.假设一直找到了0.那么说明这个作业是无法按时完毕了,就加上分数.假设某项作业完毕的最后期限比n还大,那么这个作业一定是能…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1789 题目意思: 有n个作业,每个作业有一个截止日期,每个作业如果超过截止日期完成的时候有一个惩罚值,问怎样安排作业,使惩罚值最小. 解题思路: 贪心. 先按惩罚值从大到小排序,惩罚值越大,就应该尽量安排改作业在截止日期之前完成,而怎样保证既在截止日期之前完成,又保证其他的作业的惩罚值总和较小呢,应该安排在离该截止日期最近的可安排那个日期,这样就保证了惩罚值最小. 代码: #include<ios…
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 r…
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): 4568 Accepted Submission(s): 2675 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has…
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 /*Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7903 Accepted Submission(s): 4680 Problem Description Ignatius has just c…
题目链接: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天,如果还被占用的话…
I - Doing Homework again Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description zichen 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 hand…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1221    Accepted Submission(s): 715 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he ha…
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…
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) 为了让扣分最…
题意: 给定n个点,每个点有权值a[i],从A走到B的花费是下取整sqrt(a[i]-a[j]),求从1号点走到n号点的最小花费 1<=n,a[i]<=1e5 思路: #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<iostream> #include<algorithm> #include<map> #i…
在我上一篇说到的,就是这个,贪心的做法,对比一下就能发现,另一个的扣分会累加而且最后一定是把所有的作业都做了,而这个扣分是一次性的,所以应该是舍弃扣分小的,所以结构体排序后,往前选择一个损失最小的方案直接交换就可以了. #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; struct HomeWork { int de…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17622    Accepted Submission(s): 10252 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he…
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…
Doing Homework again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10043    Accepted Submission(s): 5875 Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 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…
# Doing homework again(贪心) 题目链接:Click here~~ 题意: 有 n 门作业,每门作业都有自己的截止期限,当超过截止期限还没有完成作业,就会扣掉相应的分数.问如何才能使扣分最少. 解题思路1: 把 n 门作业按分数从大到小排序,然后每次都把作业安排在离它的截止期限最近的一天(先安排在截止日期当天,如当天已有安排,则往前一天找),并把此天标记为已用,若不能安排,则扣分. #include <iostream> #include <cstdio> #…
题目描述 Taro is a student of Ibaraki College of Prominent Computing. In this semester, he takes two courses, mathematics and informatics. After each class, the teacher may assign homework. Taro may be given multiple assignments in a single class, and ea…
Doing Homework again http://acm.hdu.edu.cn/showproblem.php?pid=1789 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 I…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1789 题目大意: 给出N个作业的截至日期,和N个作业不交所扣掉的分数,要求输出扣除分数做少的方案. 思路: 贪心, 正确的策略是: 扣除分数大的先做 扣除分数相同,先截止的先做 做一件事的时候,从截止时间开始向第一天遍历,如果当天没有被作业占据则标记为占据.做这件事的日期越大越好. 如果不能满足3的条件,则为不能完成 #include<iostream> #include<cstdio&g…
Doing Homework again 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 deadlin…
Description zichen 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 zichen hands in the homework after the deadline, the teacher will reduce his s…
题目中因为天数和分数是对应的,所以我们使用一个结构体来存分数和截止如期. 一开始做这道题的时候,很自然的就想到对天数排序,然后天数一样的分数从大到小排序,最后WA了之后才发现没有做到"舍小取大"的贪心.所以改变一下策略,对分数排序,如果分数一样的话,时间从小到大排序(因为我们的目的就是先做分多的作业,所以分数一样的得放到前几天去做). (具体sort排结构体知识见代码里面,其实也可以写两次for来排序): 思路:排好序之后,从小到大遍历,每找到一个分数,去寻找对应的天数到第一天中有没有…
题目链接:https://vjudge.net/problem/HDU-1789 题目大意: 给出N个作业的截至日期,和N个作业不交所扣掉的分数,要求输出扣除分数做少的方案. 解析: 与上一道销售商品类似,将分数从大到小排序,找到deadline,如果它的期限没有被占用,就在该天写完,然后vis置1,如果占用,则从它的前一天开始向前查找有没有空闲的日期,如果有则占用,vis置1.这样就可以得到最大分数.然后用总分数减去得到最大分数即为扣除的最小分数. #include <cstdio> #in…
题意:给出n个作业的截止时间,和该作业没有完成会被扣掉的分数.问最少会被扣掉多少分. 第一次做这一题是好久之前,当时不会(不会处理两个关键字关系@_@)---现在还是不会---看了题解---原来是这样的--- 因为要使得扣的分数尽可能少,那就先把扣分多的作业做了,即按照扣分降序排序,再遍历看该份作业能不能完成,不能完成则扣去相应的分数 #include<iostream> #include<cstdio> #include<cstring> #include<al…
FatMouse' Trade Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 56784    Accepted Submission(s): 19009 Problem Description FatMouse prepared M pounds of cat food, ready to trade with the cats g…