题目描述

Orz Panda is addicted to one RPG game. To make his character stronger, he have to fulfil tasks to get EXP for higher level.At first he accepted all the tasks.But after he read rules carefully, he realized that what he has done was stupid.
Rule:
Every task costs 1 time interval.
Every task has a dead line.If you can't finish it on time ,you have to pay the same amount of gold as the EXP given by this task.

Orz Panda wants to know the minimum amount of gold he has to pay.

输入

The first line has one integer n, tell you how many tasks Orz Panda has accepted.
The second line has n integers ti separated by blank, represent for the ith task's dead line.
The third line has n integers ei separated by blank, represent for the
EXP given by the ith task.
(1 <= n, ti, ei <= 1000)

输出

One integer for the minimum amount of gold Orz Panda has to pay.

--正文
第一想法就是贪心,想了一想按照价值排好来贪好像是对的,试了一下果然如此
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std; struct TaskNode{
int DeadLine;
int Value;
};
struct TaskNode Task[];
int used[];
bool cmp(struct TaskNode t1,struct TaskNode t2){
if (t1.Value == t2.Value) return (t1.DeadLine < t2.DeadLine);
return t1.Value > t2.Value;
} int main(){
int n;
while (scanf("%d",&n) != EOF){
int i;
for (i=;i<=n;i++){
scanf("%d",&Task[i].DeadLine);
}
for (i=;i<=n;i++){
scanf("%d",&Task[i].Value);
}
sort(Task+,Task++n,cmp);
int Ans = ;
memset(used,,sizeof(used));
for (i=;i<=n;i++){
int nowT = Task[i].DeadLine;
while (nowT > && used[nowT]) nowT--;
if (nowT == ) {
Ans += Task[i].Value;
}
else used[nowT] = ;
}
printf("%d\n",Ans);
}
return ;
}

XidianOJ 1120 Gold of Orz Pandas的更多相关文章

  1. XidianOJ 1195 Industry of Orz Pandas

    --正文 贪心 排序好慢慢找就好 #include <iostream> #include <cstring> #include <cstdio> #include ...

  2. Another Array of Orz Pandas

    Another Array of Orz Pandas 题目链接:http://acm.xidian.edu.cn/problem.php?id=1187 线段树 线段树维护区间和以及区间内各个数平方 ...

  3. Cai Xukun and Orz Pandas Gym - 102309C

    题目链接:https://vjudge.net/problem/Gym-102309C 题意:给定蔡徐坤投篮的位置和篮筐的位置以及最大初速度,求一个初速度和时间. 思路:一开始我以为要用到二分,后面仔 ...

  4. 【Codeforces】Orz Panda Cup

    大大出的题 大大经常吐槽没有人补,所以我决定做一个 A. APA of Orz Pandas 题意:给你一个包含+-*/%和()的表达式,让你把它转化成java里BigInteger的形式 大概就像这 ...

  5. BZOJ 1739: [Usaco2005 mar]Space Elevator 太空电梯

    题目 1739: [Usaco2005 mar]Space Elevator 太空电梯 Time Limit: 5 Sec  Memory Limit: 64 MB Description The c ...

  6. xdoj-1117(记忆化搜索+组合数学)

    因为我是从上到下,所以就不叫动态规划而叫记忆化搜索吧 (不过运行时间只有3ms....应该是很不错的吧) 排版怎么那么难看...编辑的时候不是这样子的啊?! 思想 : 大眼一看应该是一道很裸的状压dp ...

  7. 五、Pandas玩转数据

    Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...

  8. 利用 pandas 进行数据的预处理——离散数据哑编码、连续数据标准化

    数据的标准化 数据标准化就是将不同取值范围的数据,在保留各自数据相对大小顺序不变的情况下,整体映射到一个固定的区间中.根据具体的实现方法不同,有的时候会映射到 [ 0 ,1 ],有时映射到 0 附近的 ...

  9. pandas pivot_table 活学活用实例教程

    pandas pivot_table 活学活用实例教程 导入相关数据分析的库 首先进行commentTime时间进行数据预处理 查看数据类型信息 最简单的透视表 直接敲击该函数,在notebook中可 ...

随机推荐

  1. HDU 5838 (状压DP+容斥)

    Problem Mountain 题目大意 给定一张n*m的地图,由 . 和 X 组成.要求给每个点一个1~n*m的数字(每个点不同),使得编号为X的点小于其周围的点,编号为.的点至少大于一个其周围的 ...

  2. border-image(转载)

    本文转自:http://www.zhangxinxu.com/wordpress/2010/01/css3-border-image%E8%AF%A6%E8%A7%A3%E3%80%81%E5%BA% ...

  3. 第一次装TFS的曲折经历

    公司服务器之前TFS没装上,用的svn,实在忍受不了了,作为一个.net程序员怎么能用svn的,说动手就动手. 服务器的数据库是 SqlServer2008R2 本来想装TFS2013,后来试了一下, ...

  4. ajax 中$.each(json,function(index,item){ }); 中的2个参数表示什么意思?

    $.each(json,function(index,item)里面的index代表当前循环到第几个索引,item表示遍历后的当前对象,比如json数据为:[{"name":&qu ...

  5. Boot loader: Grub进阶[转]

    Boot loader: Grub进阶 本文记录grub的一些进阶配置 关於核心功能当中的 vga 配置 事实上,你的 tty1~tty6 除了 80x24 的解析度外,还能够有其他解析度的支持喔!但 ...

  6. MQTT协议的简单介绍和服务器的安装

    最近公司做的项目中有用到消息推送,经过多方面的筛选之后确定了使用MQTT协议,相对于XMPP,MQTT更加轻量级,并且占用用户很少的带宽. MQTT是IBM推出的一种针对移动终端设备的基于TCP/IP ...

  7. 微信接口access_token

    //调用聚合网笑话接口 $url = 'http://japi.juhe.cn/joke/img/text.from?page=&pagesize=2&key=f0d06a1fe45b ...

  8. [solr] - Facet

    Solr facet使用于分类统计,是最好的工具.下面例子使用facet将可模拟查询搜索出租房信息. 1.在schema.xml中的内容如下: <?xml version="1.0&q ...

  9. smarty3与2的差异导致的小问题

    又是一天看视频~ 今天在PHP100上学习smartY教程,视频中讲到了在模板文件中直接写带有“{}”JAVASCRIPT脚本会报错,我照视频上的代码写了下来,如下: <script> f ...

  10. MessageBox

    首先要知道MessageBox返回的值为DialogResult类型.返回值可能有如下: DialogResult.OK  //点击“确定”按钮后返回的值 DialogResult.YES  //点击 ...