hdu-1789-Doing Homework again
- /*
- 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 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
- 2007省赛集训队练习赛(10)_以此感谢DOOMIII
- Recommend
- lcy
- 本题和前面一道贪心是一样的
- */
- #include<iostream>
- #include<algorithm>
- #include<queue>
- #include<stack>
- #include<map>
- #include<stdio.h>
- #include<stdlib.h>
- #include<math.h>
- #include<string.h>
- #include<string>
- using namespace std;
- #define maxn 1010
- struct DL
- {
- int a;
- int b;
- bool operator <(const DL &d)const
- {
- return d.b<b;
- }
- } dl[maxn];
- bool v[maxn];
- int main()
- {
- int t,i,n,sum,j;
- scanf("%d",&t);
- while (t--)
- {
- memset(v,,sizeof(v));
- scanf("%d",&n);
- for(i=; i<n; i++)
- scanf("%d",&dl[i].a);
- for(i=; i<n; i++)
- scanf("%d",&dl[i].b);
- sort(dl,dl+n);
- sum=;
- for(i=;i<n;i++)
- {
- for(j=dl[i].a;j>;j--)
- {
- if(!v[j])
- {
- v[j]=;
- break;
- }
- }
- if(j==)
- {
- sum+=dl[i].b;
- }
- }
- printf("%d\n",sum);
- }
- return ;
- }
hdu-1789-Doing Homework again的更多相关文章
- hdu 1789 Doing HomeWork Again (贪心算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 /*Doing Homework again Time Limit: 1000/1000 MS ...
- HDU 1789 Doing Homework again (贪心)
Doing Homework again http://acm.hdu.edu.cn/showproblem.php?pid=1789 Problem Description Ignatius has ...
- HDU 1789 - Doing Homework again - [贪心+优先队列]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 Time Limit: 1000/1000 MS (Java/Others) Memory Li ...
- HDU 1789 Doing Homework again(非常经典的贪心)
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 题解报告:hdu 1789 Doing Homework again(贪心)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1789 Problem Description Ignatius has just come back ...
- HDU 1789 Doing Homework again(贪心)
Doing Homework again 这只是一道简单的贪心,但想不到的话,真的好难,我就想不到,最后还是看的题解 [题目链接]Doing Homework again [题目类型]贪心 & ...
- HDU 1789 Doing Homework again(贪心)
在我上一篇说到的,就是这个,贪心的做法,对比一下就能发现,另一个的扣分会累加而且最后一定是把所有的作业都做了,而这个扣分是一次性的,所以应该是舍弃扣分小的,所以结构体排序后,往前选择一个损失最小的方案 ...
- HDU 1789 Doing Homework again(馋)
意甲冠军 参加大ACM竞争是非常回落乔布斯 每一个工作都有截止日期 未完成必要的期限结束的期限内扣除相应的积分 求点扣除的最低数量 把全部作业按扣分大小从大到小排序 然后就贪阿 能完毕 ...
- HDU 1789 Doing Homework again(排序,DP)
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- hdu 1789 Doing Homework again (Greedy)
Problem - 1789 继续贪心.经典贪心算法,如果数据比较大就要用线段树来维护了. 思路很简单,只要按照代价由大到小排序,然后靠后插入即可.RE了一次,是没想到deadline可以很大.如果d ...
随机推荐
- 利用多写Redis实现分布式锁原理与实现分析(转)
利用多写Redis实现分布式锁原理与实现分析 一.关于分布式锁 关于分布式锁,可能绝大部分人都会或多或少涉及到. 我举二个例子:场景一:从前端界面发起一笔支付请求,如果前端没有做防重处理,那么可能 ...
- [下载] MultiBeast 6.2.1版,支持10.9 Mavericks。Mac上的驱动精灵,最简单安装驱动的方式。
下载地址1:http://pan.baidu.com/s/1i3ier9F 下载地址2:http://www.tonymacx86.com/downloads.php?do=cat&id=3 ...
- 自定义View_1_关于View,ViewGroup的测量和绘制流程
自定义View(1) ------ 关于View,ViewGroup的测量和绘制流程 在Android当中,自定义控件属于比较高级的知识体系,今天我们就一起研究研究关于自定义View的那点事,看看它到 ...
- 如何给span设置高度宽度?
内容提要:给Span设置高度和宽度后没有作用.本文介绍了如何如何给span设置高度宽度. CSS模型中经常用的容器是DIV和span. 给Span设置高度和宽度后没有作用. <style typ ...
- The main concepts
The MVC application model A Play application follows the MVC architectural pattern applied to the we ...
- c++类的定义《一》
最近好忙,一来要在店里看店,二来朋友办结婚酒,搞的我这几天好疲惫啊···博客又有好几天没提笔了. 下午简单看了下书,看到了类的部分,自己动手练习了一下 笔记:1.类是数据类型 / 它的变童就是对象 ...
- 初识 Android
创建博客有一年的时间了,一直没把它用起来,颇感惭愧.近日突感有写博客的冲动,更可怕的是这种冲动似乎比我体内的洪荒之力更为凶猛.于是乎,这篇博客悄然诞生.废话不多说,进入正题--初识Android. 这 ...
- MAC中安卓开发环境的下载(转)
今天终于为我的Macbook Pro Retina搭建好了Android开发环境,几经折磨,差点放弃了: 总结如下:1.最好选择ADT Bundle,这里面已经集成好了Eclipse.ADT.Andr ...
- Objective-C之Block
Block基本概念 本小节知识点: [了解]什么是Block [理解]block的格式 1.什么是Block Block是iOS中一种比较特殊的数据类型 Block是苹果官方特别推荐使用的数据类型, ...
- Java眼中的XML--文件读取--2 应用SAX方式解析XML
1.获取一个SAXParserFactory的实例.2.通过factory获取SAXParser实例. 3.新建一个包和继承自DefaultHandler的类. 因为SAX遍历方式,比如便利一个节 ...