I - Doing Homework again
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d
& %I64u
Description
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
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
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
5my answer:#include<iostream>
#include<algorithm>
using namespace std;
typedef struct st{
int day;
int score;
}st;
bool cmp(st a,st b){
return a.score>b.score;
}
int main()
{
int n,T;
cin>>T;
while(cin>>n)
{
st a[1000];
int vis[1000]={0};
for(int i=0;i!=n;i++)
cin>>a[i].day;
for(int i=0;i!=n;i++)
cin>>a[i].score;
int b[1000];
sort(a,a+n,cmp);
int sum=0;
for(int j=0;j<n;j++){
if(vis[a[j].day]){ int k=a[j].day;
while(k>0&&vis[k])k--;
if(k<=0){sum+=a[j].score;}
else vis[k]=1;
}
else
{
vis[a[j].day]=1;
}
}
cout<<sum<<endl;
}
return 0;
}
I - Doing Homework again的更多相关文章
- bzoj 4320: ShangHai2006 Homework
4320: ShangHai2006 Homework Time Limit: 10 Sec Memory Limit: 128 MB Description 1:在人物集合 S 中加入一个新的程序员 ...
- HDU 1789 Doing Homework again(贪心)
Doing Homework again 这只是一道简单的贪心,但想不到的话,真的好难,我就想不到,最后还是看的题解 [题目链接]Doing Homework again [题目类型]贪心 & ...
- 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 (贪心)
Doing Homework again http://acm.hdu.edu.cn/showproblem.php?pid=1789 Problem Description Ignatius has ...
- Doing Homework 状态压缩DP
Doing Homework 题目抽象:给出n个task的name,deadline,need. 每个任务的罚时penalty=finish-deadline; task不可以同时做.问按怎样的 ...
- 机器学习 —— 概率图模型(Homework: Exact Inference)
在前三周的作业中,我构造了概率图模型并调用第三方的求解器对器进行了求解,最终获得了每个随机变量的分布(有向图),最大后验分布(双向图).本周作业的主要内容就是自行编写概率图模型的求解器.实际上,从根本 ...
- hdoj 1789 Doing Homework again
Doing Homework again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- homework做了些什么?
第一步:get_new_guid_uid_pairs_{$ymd} 参数是时间和100上的文件. 那么100上的文件是从哪里来的呢? 我们进入到100机器上,打开root权限下的cron,看到如下内容 ...
- HDU 1074 Doing Homework (dp+状态压缩)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1074 题目大意:学生要完成各科作业, 给出各科老师给出交作业的期限和学生完成该科所需时间, 如果逾期一 ...
- hdu1074 Doing Homework(状态压缩DP Y=Y)
Doing Homework Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
随机推荐
- python代码中pass的用法
我们有时会在方法中写一些注释代码,用来提示这个方法是干嘛的之类,看下面代码: class Game_object: def __init__(self, name): self.name = name ...
- POJ2063 Investment 【全然背包】
Investment Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 8019 Accepted: 2747 Descri ...
- supersocket--SuperSocket 1.4系列文档(1) 第一个例子, EchoService
First example, EchoService 1. 新建一个名叫 “EchoService” 的空白项目 2. 添加SuperSocket的Common和SocketBase这两个dll或者项 ...
- NHibernate 3.3
今天试了一下NHibernate 3.3比之前的版本简单,只需要引入两个dll,这两个dll分别是:Iesi.Collections.dll和NHibernate.dll 通过 http://nhfo ...
- 修改SharePoint平台登录者显示名称
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //提升权限,拿系统服务帐号来执行此段代码 ...
- CentOS安装maven3.2.2(Linux系列适用)
首先,下载最新的maven3.2.2,地址:http://mirrors.cnnic.cn/apache/maven/maven-3/3.2.2/binaries/apache-maven-3.2.2 ...
- 20151203--filter
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/htm ...
- leetcode Invert Binary Tree python
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = ...
- VB EditGrid的用法
百度了一下,关于vb 6.0 EditGrid的用法 查不到资料
- 关于QT、GCC、GNU下各个版本的下载地址
http://download.qt.io/ http://ftp.gnu.org/gnu/gcc/ http://ftp.gnu.org/pub/gnu/