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 ...
随机推荐
- DataSet导出到Excel,并生成文件(C#实现,可合并行和列)
using System; using System.IO; using System.Data; using System.Reflection; using System.Diagnostics; ...
- 【BZOJ 4326】【NOIP2015】运输计划
http://www.lydsy.com/JudgeOnline/problem.php?id=4326 题目描述 公元2044年,人类进入了宇宙纪元. 国有个星球,还有条双向航道,每条航道建立在两个 ...
- Scala Collection简介
Traversable vs Iterable Traversable, Iterable 都是trait. Iterable 继承 Traversable. Traversable: 支持forea ...
- ASP.NET Web API通过ActionFilter来实现缓存
using System; using System.Collections.Generic; using System.Linq; using System.Threading; using Sys ...
- rabbitmq学习笔记1 安装和配置
环境 OS: CentOS Linux release 7.1.1503 (Core) kernel:3.10.0-229.el7.x86_64 安装 参考:http://www.rabbitmq ...
- javascript --- 子对象访问父对象的方式
在传统面向对象的编程语言里,都会提供一种子类访问父类的特殊语法,引文我们在实现子类方法往往需要父类方法的额外辅助.在这种情况下,子类通常会调用父类中的同名方法,最终以便完成工作. javascript ...
- jQuery高级技巧——DOM操作篇
页面加载之DOMReady事件 所谓domReady,也就是文档就绪,我们都知道,在操作dom时必须要在dom树加载完成后才能进行操作.如何检测DOM树已经构建完成,以下是一些实现的方式: 1.使 ...
- Creating External Lists From Code
You can create an external list based on an entity (external content type) defined in SharePoint Bus ...
- IOS开发之实现App消息推送(最新)
好久没有写过博客啦,今天就由本菜鸟给大家做一个简单的IOSApp消息推送教程吧!一切从0开始,包括XCode6, IOS8, 以及苹果开发者中心最新如何注册应用,申请证书以及下载配置概要文件,相信很多 ...
- iOS开发中常用方法调用顺序