意甲冠军  参加大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

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
 

版权声明:本文博主原创文章。博客,未经同意不得转载。

HDU 1789 Doing Homework again(馋)相关推荐

  1. hdu 1789 Doing Homework again

    又是一次初始化惹的货!!! 超级水的贪心...害的我以为思路错误~~ ~ #include<iostream>#include<cstdio>#include<cmath ...

  2. HDU 1789 Doing Homework again (贪心)

    http://blog.csdn.net/dgq8211/article/details/7538060 题目链接:Click here~~ 题意: 有 n 门作业,每门作业都有自己的截止期限,当超过 ...

  3. hdu 1789 贪心算法

    http://acm.hdu.edu.cn/showproblem.php?pid=1789 此题大致思路,既然要计算最少扣多少分,就要在最后时间之前把扣分最多的作业先安排了.如果扣分一样多的话,那必 ...

  4. hdu 1789题解

    http://acm.hdu.edu.cn/showproblem.php?pid=1789: 这个题目就是用贪心的思想来做,首先按分数从高到底排下序,然后在判断哪几个不能完成时用到了一个小技巧. # ...

  5. HDU 1074 Doing Homework【状态压缩DP】

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1074 题意: 给定作业截止时间和完成作业所需时间,比截止时间晚一天扣一分,问如何安排作业的顺序使得最 ...

  6. hdu - 1789 题解

    题意:主角打完ACM比赛回来,有一堆作业要做,每个作业有自己的deadline和score,如果不能在deadline之前完成就拿不到这个作业的分数,问主角最多能拿多少分. 题解:还是贪心策略,将作业 ...

  7. 8-14-Exercise

    8-14-小练 这次是我这组出题......我出的是B.C.D[虽然本来是想出的很难......╮(╯▽╰)╭但是,没找到AC1000+同时又让我想出的难题......SO...我出的真的不难= =] ...

  8. 杭电OJ分类题目(3)

    原题出处:HDOJ Problem Index by Type,http://acm.hdu.edu.cn/typeclass.php 杭电OJ分类题目(3) HDU Computational Ge ...

  9. kuangbin带你飞专题合集

    题目列表 [kuangbin带你飞]专题一 简单搜索 [kuangbin带你飞]专题二 搜索进阶 [kuangbin带你飞]专题三 Dancing Links [kuangbin带你飞]专题四 最短路 ...

最新文章

  1. 创建交叉表_【零售】Tableau LOD+表计算做交叉购买分析
  2. linux 界面工具 qt,Qt主窗口中的工具栏
  3. python django ansible自动化运维管理平台源码收藏
  4. docker二进制代码编译
  5. Android系统匿名共享内存Ashmem(Anonymous Shared Memory)在进程间共享的原理分析
  6. English trip -- VC(情景课)2 D Reading
  7. C语言字符串倒排,C语言兑现简单的倒排文件索引
  8. stm32定时2通道3映射_stm32学习笔记之问题总结
  9. 虚函数如何实现多态 ?
  10. html左斜杠转义字符,html的右斜杠转义符号是什么呢
  11. 英语四六级网站服务器繁忙,英语四六级成绩公布这些问题很常见
  12. php博客平台 开源,PHP开源博客Blog - PHP开源网(PHP-OPEN.ORG)
  13. pycharm更换国内源
  14. 完全认识计算机网络之TCP/IP
  15. 笨办法学Python笔记2(ex18~ex40)
  16. MATLAB计算黎曼积分曲线围成的面积
  17. GeneXus项目启动
  18. MySQL运维进阶必备
  19. python如何读取weboutlook内容_用Python通过MAPI读取Outlook中的电子邮件
  20. 怎样设置win10电脑的默认浏览器?技巧经验!win10系统的默认浏览器如何设定?

热门文章

  1. elasticsearch 索引_Elasticsearch系列---索引管理
  2. java自定义键值对_KV键值对数据类型
  3. 计算机入域时域控用到的端口,【ADDC】域控需要开放的端口
  4. python中parse是什么_python中的configparse学习笔记
  5. 将服务器文件加载至hive表中,Hive入门到剖析(四)
  6. php mongodb 子查询,MongoDB数组子查询elemMatch
  7. 计算机组装图示,台式机组装教程-台式机DIY装机教程示意图(自己动手组装电脑)...
  8. Java反射课程教程
  9. OCJP认证考试复习课-张晨光-专题视频课程
  10. 本地存储localStorage