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 ...
随机推荐
- Android Material风格的应用(四)--FloatActionButton
添加 FloatActionButton和SnackBar Android Material风格的应用(一)--AppBar TabLayoutAndroid Material风格的应用(二)--Re ...
- amazeui学习笔记--css(布局相关1)--网格Grid
amazeui学习笔记--css(布局相关1)--网格Grid 一.总结 基本使用 1.div+class布局:amaze里面采取的就是div+class的布局方式 <div class=&q ...
- RMAN异机复制数据库(相同路径)
有完整的备份,新的数据库datafile.controfile.logfile所在目录结构和原数据库一样. 创建好adump.bdump.cdump.udump等目录. 1.恢复参数文件. 设置环境变 ...
- 希捷硬盘扩容软件-----DiscWizard
SeagateDiscWizard可为Seagate磁盘驱动器的使用提供便利.DiscWizard可帮助您迅速安装新的磁盘驱动器.并通过安装向导指导您在磁盘驱动器上完毕分区的创建和格式化. DiscW ...
- linux内核头文件 cdev.h 解析
遇到一个内核API--cdev_init 就找到这里来了. #ifndef _LINUX_CDEV_H #define _LINUX_CDEV_H #include <linux/kobject ...
- Spring的资源抽象Resource2实体类
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAA0UAAAGkCAIAAABxYhnsAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWX ...
- 【t086】防护伞
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 据说2012的灾难和太阳黑子的爆发有关.于是地球防卫小队决定制造一个特殊防护伞,挡住太阳黑子爆发的区域 ...
- 数据类型总结——Boolean类型(布尔类型)
相关文章 简书原文:https://www.jianshu.com/p/e5c75d4be636 数据类型总结——概述:https://www.cnblogs.com/shcrk/p/9266015. ...
- Kinect 骨骼映射---Let me dance for U!
本文章由cartzhang编写,转载请注明出处. 所有权利保留. 文章链接: http://blog.csdn.net/cartzhang/article/details/45583443 作者:ca ...
- 【TP SRM 703 div2 250】AlternatingString
Problem Statement A string of zeros and ones is called an alternating string if no two adjacent char ...