题目描述

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. E - 滑雪

    Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Pract ...

  2. MYSQL安装--小白教程

    这个是mysql的安装过程,其实mysql的安装也很简单,但是我安装了一下午!!一下午!!原因就是,我把mysql的官网都翻遍了,都没找到64bit的.msi安装包,后来才想到好像64bit的电脑可以 ...

  3. Nginx-ngx_lua模块原理和内置函数

    ngx_lua模块的原理: 1.每个worker(工作进程)创建一个Lua VM,worker内所有协程共享VM:2.将Nginx I/O原语封装后注入 Lua VM,允许Lua代码直接访问:3.每个 ...

  4. python(pymysql)之mysql简单操作

    一.mysql简单介绍 说到数据库,我们大多想到的是关系型数据库,比如mysql.oracle.sqlserver等等,这些数据库软件在windows上安装都非常的方便,在Linux上如果要安装数据库 ...

  5. CSS 分组

    选择器分组 假设希望 h2 元素和段落都有灰色.为达到这个目的,最容易的做法是使用以下声明: h2, p {color:gray;} 将 h2 和 p 选择器放在规则左边,然后用逗号分隔,就定义了一个 ...

  6. VC运行库合集2005/2008/2010/2012/2013/2015

    VC运行库合集2005/2008/2010/2012/2013/2015,批处理一键安装(需管理员权限) 链接:http://pan.baidu.com/s/1bpLZoFt 密码:bnk8

  7. MVC:上传文件时限制文件类型

    之前写过一篇:MVC:上传文件 今天补充下一个功能:如何限制上传文件类型 文件类型可以在前段限制,但是太容易被绕过,最好还是在后端处理. 修改upload方法代码: [HttpPost] public ...

  8. 关于oracle修复控制文件与数据文件不一致的问题----

    本小菜鸟周末鼓捣数据库关于rman恢复与备份方面的实验,结果不知道哪根筋搭错了,手一哆嗦,做了不知道什么操作,就出现了数据库打不开的严重状态,只能开启到mount状态,但是切换到open状态时就会报错 ...

  9. Vmware web client 5.5 控制台连接不上:Connection timed out

    因XP下安装vsphere client5.5后,无法连接远程vsphere.因此使用vsphere web client. 但是用vsphere web client打开控制台,报错:Conneti ...

  10. silverlight简单数据绑定1

    数据绑定是用户界面与数据源之间的媒介:通过绑定可以使数据在界面和数据源之间传递交流.数据绑定由System.Windows.Data命名空间的Binding对象完成. 创建绑定的数据对象类. .cs类 ...