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 ...
随机推荐
- mysql 表的timestamp为自动添加
新设计表时可以执行语句: `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP C ...
- uvalive 6393(uva 1572) Self-Assembly 拓扑排序
题意: 给出一些正方形,这些正方形的每一条边都有一个标号.这些标号有两种形式:1.一个大写字母+一个加减号(如:A+, B-, A-......), 2.两个0(如:00):这些正方形能够任意翻转和旋 ...
- @RequestMapping value 能够反复吗 [
@RequestMapping value 能够反复吗 [问题点数:40分,结帖人wangqiao4j] 不显示删除回复显示全部回复 显示星级回复显示得分回复 仅仅显示楼主 u=http://bbs. ...
- amazeui学习笔记--js插件(UI增强4)--下拉组件Dropdown
amazeui学习笔记--js插件(UI增强4)--下拉组件Dropdown 一.总结 1.am-dropdown(及其孩子):控制下拉列表的样式 2.data-am-dropdown(及其孩子):控 ...
- Redis学习笔记--String(四)
Redis的第一个数据类型string 1.命令 1.1赋值 语法:SET key value Set key value; > OK 1.2取值 语法:GET key > get tes ...
- vuex概念总结及简单使用实例
原文 简书原文:https://www.jianshu.com/p/0546983f5997 大纲 1.什么是Vuex 2.什么是“状态管理模式”? 3.什么情况下应该使用 Vuex? 4.Vuex和 ...
- Mac怎么设置wifi热点
苹果 Mac 系统中要把无线当作 Wifi 热点来用的话,需要电脑有其它网络接入才可以,也就是说它需要一个可以用于上网的网络,比如有线网络.尤其是对于使用 MacBook Pro 或 MacBook ...
- 【Codeforces Round #437 (Div. 2) C】 Ordering Pizza
[链接]h在这里写链接 [题意] 给你参赛者的数量以及一个整数S表示每块披萨的片数. 每个参数者有3个参数,si,ai,bi; 表示第i个参赛者它要吃的披萨的片数,以及吃一片第 ...
- 切换根控制器UIApplication 主屏幕UIScreen 读取文件资源NSBundle
//主屏幕设为webView CGRect frame = [UIScreen mainScreen].applicationFrame; UIWebView *webView = [[[UIWebV ...
- [CSS3] Create a fixed-fluid-fixed layout using CSS calc()
CSS calc() allows you to mix and match units to get real-time calculations. It's useful when you nee ...