HDU - 1789 贪心】的更多相关文章

贪心策略:按照分数降序排列,如果分数相同将截止时间早的排在前面.每次让作业尽量晚完成,因此需要逆序枚举判断这一天是否已经做了其他作业,如果没时间做这个作业说明不能完成,否则将这一天标记. AC代码 #include <cstdio> #include <cmath> #include <algorithm> #include <cstring> #include <utility> #include <string> #include…
题意 给出n门作业的截止时间与分数 如果不能在那天结束前做完就扣掉相应分数 问怎么安排能让扣分最少 思路 先按分数从大到小排序 先研究大的 做好标记 一开始每天都能放作业 全是true 如果这一天已经有作业了 就往前寻找true的一天 如果没有寻找到就扣分 之前wa了好多次 是因为输入n后 node a[n+1] bool b[n+1] 后来改成node a[1050] bool b[1050]就可以了 #include<stdio.h> #include<string.h> #i…
第一题;http://acm.hdu.edu.cn/showproblem.php?pid=1257 贪心与dp傻傻分不清楚,把每一个系统的最小值存起来比较 #include<cstdio> using namespace std; ],b[]; int main() { int n,i,j; while (~scanf("%d",&n)) { ; b[]=-; ;i<n;i++) { scanf("%d",&a[i]); ;j&l…
题目链接: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 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…
题目链接: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 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…
Doing Homework again 这只是一道简单的贪心,但想不到的话,真的好难,我就想不到,最后还是看的题解 [题目链接]Doing Homework again [题目类型]贪心 &题意: Ignatius有N项作业要完成.每项作业都有限期,如果不在限期内完成作业,期末考就会被扣相应的分数.给出测试数据T表示测试数,每个测试以N开始(N为0时结束),接下来一行有N个数据,分别是作业的限期,再有一行也有N个数据,分别是若不完成次作业会在期末时被扣的分数.求出他最佳的作业顺序后被扣的最小的…
在我上一篇说到的,就是这个,贪心的做法,对比一下就能发现,另一个的扣分会累加而且最后一定是把所有的作业都做了,而这个扣分是一次性的,所以应该是舍弃扣分小的,所以结构体排序后,往前选择一个损失最小的方案直接交换就可以了. #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; struct HomeWork { int de…