HDU 1789 Doing Homework again(馋)
意甲冠军 参加大ACM竞争是非常回落乔布斯 每一个工作都有截止日期 未完成必要的期限结束的期限内扣除相应的积分 求点扣除的最低数量
把全部作业按扣分大小从大到小排序 然后就贪阿 能完毕前面的就完毕前面的 实在不能的就扣分吧~
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 1005;
int dli[N], red[N], k[N], cas, ans, n;
bool vis[N]; bool cmp (int i, int j)
{
return red[i] > red[j];
} int main()
{
scanf ("%d", &cas);
while (cas--)
{
ans = 0;
memset (vis, 0, sizeof (vis));
scanf ("%d", &n);
for (int i = 1; i <= n; ++i)
scanf ("%d", &dli[i]), k[i] = i;
for (int j = 1; j <= n; ++j)
scanf ("%d", &red[j]); sort (k + 1, k + n + 1, cmp);
for (int i = 1, j; i <= n; ++i)
{
for (j = dli[k[i]]; j >= 1; --j)
if (!vis[j])
{
vis[j] = 1;
break;
}
if (j == 0) ans += red[k[i]];
}
printf ("%d\n", ans);
}
return 0;
}<span style="font-family:Comic Sans MS;">
</span>
Doing Homework again
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.
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.
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
0
3
5
版权声明:本文博主原创文章。博客,未经同意不得转载。
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(排序,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 ...
随机推荐
- crm翻译导航栏
在crm里面怎样翻译导航栏? 过程例如以下: 1 先新建一个解决方式.把网站地图加进去 2: 然后把这个解决方式到出来来,解压文件: 3:编辑第二个文件: watermark/2/text/aHR0c ...
- [Angular] The Select DOM Event and Enabling Text Copy
When we "Tab" into a input field, we want to select all the content, if we start typing, i ...
- NDIS
NDIS NDIS(NetworkDriverInterfaceSpecification)是网络驱动程序接口规范的简称.它横跨传输层.网络层和数据 链路层,定义了网卡或网卡驱动程序与上层协议驱动程序 ...
- ivotal-tc-Server与Tomcat区别
Pivotal-tc-Server之前叫做SpringSource tc Server,包含三个版本分别是:Spring版.标准版和开发版,但其中只有开发版是免费的.比如在STS中包含的版本就是开发板 ...
- CSDN日报20170406 ——《代码非常烂,所以离职。》
[程序人生]代码非常烂.所以离职? 作者:stormzhang 我在面试的时候一般会问这么一个问题:你为什么离职? 当中有不少同学会提到这么一个原因.现在的项目代码太烂了,前人留下了非常多坑,我实在忍 ...
- WPF应用程序启动的问题(自定义Main函数启动)
问题引入: 一般WPF创建之后可以直接运行并不需要编写Main函数指定入口,但是在开发的过程中会遇到一些情况需要自定义Main让WPF从指定的Main函数中进行启动,这样可能会更好控制一点.但是我们再 ...
- 与Eclipse关于"Call Hierarchy"和"Find Reference"功能比较
"Call Hierarchy"功能比较 Eclipse的"Call Hierarchy"可以查看一个Java方法或类成员变量的调用树(caller和calle ...
- 小白学开发(iOS)OC_ 使用继承来扩充类(2015-08-07)
// // main.m // 使用继承来扩充类 // // Created by admin on 15/8/12. // Copyright (c) 2015年 admin. All ri ...
- libiconv库链接问题一则
https://blog.csdn.net/jeson2090/article/details/54632063 出现过glibc中的iconv_open返回EINVAL,原因猜测是有些字符集转换不支 ...
- 解决gvim 8.1中zip插件打开zip文件内容时,而文件路径带有空格的问题。
解决gvim 8.1中zip插件打开zip文件内容时,而文件路径带有空格的问题. 现象是只能打开一次,第二次打开就显示为空了. 通过 lcd切换工作目录.使得命令行操作中不再有带空格的路径 vim81 ...