hdoj 1789 Doing Homework again
Doing Homework again
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8638 Accepted Submission(s):
5090
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.
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.
total reduced score, one line per test case.
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
struct record
{
int day;
int score;
}num[1100];
bool cmp(record a,record b)
{
if(a.score!=b.score)
return a.score>b.score;
else
return a.day<b.day;
}
int main()
{
int n,m,j,i,t,l,sum;
int vis[1100];//用来储存必须要占用的日期
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
memset(vis,0,sizeof(vis));
for(i=0;i<n;i++)
scanf("%d",&num[i].day);
for(i=0;i<n;i++)
scanf("%d",&num[i].score);
sort(num,num+n,cmp);
sum=0;
for(i=0;i<n;i++)
{
for(j=num[i].day;j>=1;j--)
{
if(vis[j]==0)
{
vis[j]=1;
break;
}
}
if(j==0)
sum+=num[i].score;
}
printf("%d\n",sum);
}
return 0;
}
hdoj 1789 Doing Homework again的更多相关文章
- HDOJ.1789 Doing Homework again (贪心)
Doing Homework again 点我挑战题目 题意分析 给出n组数据,每组数据中有每份作业的deadline和score,如果不能按期完成,则要扣相应score,求每组数据最少扣除的scor ...
- Hdoj 1789 Doing Homework again 题解
Problem Description Ignatius has just come back school from the 30th ACM/ICPC. Now he has a lot of h ...
- 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(贪心)
在我上一篇说到的,就是这个,贪心的做法,对比一下就能发现,另一个的扣分会累加而且最后一定是把所有的作业都做了,而这个扣分是一次性的,所以应该是舍弃扣分小的,所以结构体排序后,往前选择一个损失最小的方案 ...
随机推荐
- WinForm聊天室
前几天开始学Socket编程,跟着老师一点一点的做.最后做了一个WinForm版的小聊天室.这个聊天室的客户端和服务端都只是在本机上运行. 这里我首先和大家谈谈我对聊天室的一点理解,聊天室其实是服务端 ...
- php发送http请求
http请求有get,post. php发送http请求有三种方式[我所知道的有三种,有其他的告诉我]. file_get_contents();详情见:http://www.cnblogs.com/ ...
- MySQL数据库的热备份和冷备份
冷备份(off, 慢, 时间点上恢复)冷备份发生在数据库已经正常关闭的情况下,当正常关闭时会提供给我们一个完整的数据库.冷备份是将关键性文件拷贝到另外位置的一种说法.对于备份数据库信息而言,冷备份是最 ...
- [Jquery] js获取浏览器滚动条距离顶端的距离
需要用js获取滚动条距离窗口顶端的距离和js获取浏览器可视化窗口的大小 一.jQuery获取的相关方法 jquery 获取滚动条高度 获取浏览器显示区域的高度 : $(window).height( ...
- uva 10652 Board Wrapping
主要是凸包的应用: #include <cstdio> #include <cmath> #include <cstring> #include <algor ...
- underscore demo
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 快速搭建PHP开发环境(PhpStorm+EasyPHP)
写在开头,何为PHP(拍黄片)? P HP是一种开源的通用计算机脚本语言,尤其适用于网络开发并可嵌入HTML中使用(维基百科). 从上我们得出,何为PHP? 1.开源脚本语言. 2.用于网络开发可嵌入 ...
- http://www.cnblogs.com/xdp-gacl/p/3951952.html
http://www.cnblogs.com/xdp-gacl/p/3951952.html http://www.cnblogs.com/kristain/articles/2409021.html
- [转贴]Eclipse IDE for c++配置
从工作到现在已经有快一年多没用过C/C++了,现在想重新捡起来,但是以前一直是在windows下面进行开发,使用最多的是Eclipse和Myeclipse,因为这些都是开源的软件,并不收费,所以现在也 ...
- INFORMATION_SCHEMA.INNODB_TRX 详解
从192.168.11.186 上登录 192.168.11.185 数据库: root 13246 547 0 13:39 pts/1 00:00:00 mysql -uroot -px xxxxx ...