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(贪心)
在我上一篇说到的,就是这个,贪心的做法,对比一下就能发现,另一个的扣分会累加而且最后一定是把所有的作业都做了,而这个扣分是一次性的,所以应该是舍弃扣分小的,所以结构体排序后,往前选择一个损失最小的方案 ...
随机推荐
- netbeans git 配置(ssh方式)
git出问题了,自己又重新配置了下git. 参考文章: https://netbeans.org/kb/docs/ide/git_zh_CN.html#github
- [About me] 关于Alima博主
大家好,欢迎来到我的博客,我是博主Alima. 关于我,一个从岛国工作刚刚失望回国的90后男孩子,被日企伤的很难过. 迫切的想改变现在的一切,想换个城市换个工作方向,重新开始. 如果你,觉得我的博客写 ...
- Servlet 的由来和实现过程
Servlet 是在服务器上运行的小程序.这个词是在 Java applet的环境中创造的,Java applet 是一种当作单独文件跟网页一起发送的小程序,它通常用于在客户端运行,结果 ...
- 黑马程序员-------.net基础知识二
变量 变量代表着一块内存空间,我们可以通过变量名称想内存存/取数据,有变量就不需要我们记忆复杂的内存地址. 向内存中申请一块内存空间的语法: 数据类型 变量名; 变量类型 变量类型 存储位置 自动 ...
- POJ 1442 Black Box 堆
题目: http://poj.org/problem?id=1442 开始用二叉排序树写的,TLE了,改成优先队列,过了.. 两个版本都贴一下吧,赚稿费.. #include <stdio.h& ...
- Forget asp.net membership,ASP.NET Identity Overview
http://www.asp.net/identity http://www.asp.net/identity/overview/getting-started/introduction-to-asp ...
- python的方法总结:
1. Python的字典的items(), keys(), values()都返回一个list >>> dict = { 1 : 2, 'a' : 'b', 'hello' : 'w ...
- python加密解密
from Crypto.Cipher import Blowfish #easy_install pycrypto可以获得
- 【HDOJ】1175 连连看
BFS.wa了一下午,原来是YES,写成了Yes. #include <iostream> #include <cstdio> #include <cstring> ...
- Redundant Call to Object.ToString()
Redundant Call to Object.ToString() The + operator for string is overloaded to call String.Concat pa ...