XidianOJ 1120 Gold of Orz Pandas
题目描述
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的更多相关文章
- XidianOJ 1195 Industry of Orz Pandas
--正文 贪心 排序好慢慢找就好 #include <iostream> #include <cstring> #include <cstdio> #include ...
- Another Array of Orz Pandas
Another Array of Orz Pandas 题目链接:http://acm.xidian.edu.cn/problem.php?id=1187 线段树 线段树维护区间和以及区间内各个数平方 ...
- Cai Xukun and Orz Pandas Gym - 102309C
题目链接:https://vjudge.net/problem/Gym-102309C 题意:给定蔡徐坤投篮的位置和篮筐的位置以及最大初速度,求一个初速度和时间. 思路:一开始我以为要用到二分,后面仔 ...
- 【Codeforces】Orz Panda Cup
大大出的题 大大经常吐槽没有人补,所以我决定做一个 A. APA of Orz Pandas 题意:给你一个包含+-*/%和()的表达式,让你把它转化成java里BigInteger的形式 大概就像这 ...
- BZOJ 1739: [Usaco2005 mar]Space Elevator 太空电梯
题目 1739: [Usaco2005 mar]Space Elevator 太空电梯 Time Limit: 5 Sec Memory Limit: 64 MB Description The c ...
- xdoj-1117(记忆化搜索+组合数学)
因为我是从上到下,所以就不叫动态规划而叫记忆化搜索吧 (不过运行时间只有3ms....应该是很不错的吧) 排版怎么那么难看...编辑的时候不是这样子的啊?! 思想 : 大眼一看应该是一道很裸的状压dp ...
- 五、Pandas玩转数据
Series的简单运算 import numpy as np import pandas as pd s1=pd.Series([1,2,3],index=['A','B','C']) print(s ...
- 利用 pandas 进行数据的预处理——离散数据哑编码、连续数据标准化
数据的标准化 数据标准化就是将不同取值范围的数据,在保留各自数据相对大小顺序不变的情况下,整体映射到一个固定的区间中.根据具体的实现方法不同,有的时候会映射到 [ 0 ,1 ],有时映射到 0 附近的 ...
- pandas pivot_table 活学活用实例教程
pandas pivot_table 活学活用实例教程 导入相关数据分析的库 首先进行commentTime时间进行数据预处理 查看数据类型信息 最简单的透视表 直接敲击该函数,在notebook中可 ...
随机推荐
- ecshop 常见问题汇总
下面68ECSHOP开发中心就和大家说说ecshop使用中常见的问题 1.如何修改网站"欢迎光临本店" 回答(1) languages\zh_cn\common.php ...
- python数据结构与算法——图的基本实现及迭代器
本文参考自<复杂性思考>一书的第二章,并给出这一章节里我的习题解答. (这书不到120页纸,要卖50块!!,一开始以为很厚的样子,拿回来一看,尼玛.....代码很少,给点提示,然后让读者自 ...
- c语言二叉树基本操作
编译器为vs2013 #include "stdafx.h" #include<malloc.h> #include<stdlib.h> #define O ...
- android数据存储之Sqlite(二)
SQLite学习笔记 前言:上一章我们介绍了sqlite的一些基本知识以及在dos命令下对sqlite进行的增删改查的操作,这一章我们将在android项目中实际来操作sqlite. 1. SQLit ...
- MongoDB丢数据问题的分析
坊间有很多传说MongoDB会丢数据.特别是最近有一个InfoQ翻译的Sven的一篇水文(为什么叫做水文?因为里面并没有他自己的原创,只是搜罗了一些网上的博客,炒了些冷饭吃),其中又提到了丢数据的事情 ...
- 2016中国VR开发者论坛第一期
由VR界网和暴风魔镜联合举办的2016中国VR开发者论坛第一期已于3月2日下午5点在吉林动画学院圆满落幕,本次论坛云集了VR相关领域的精英,邀请了VR社交<极乐王国>.暴风魔镜.南京睿悦. ...
- 用JavaScript动态加载CSS和JS文件
本文转载自:http://www.cnblogs.com/xiaochaohuashengmi/archive/2011/11/14/2248451.html 今天项目中需要用到动态加载 CSS 文件 ...
- 本地和VMware虚拟主机之间的网络访问
在需要设置的虚拟主机节点上右键,点击[设置...] 在打开的虚拟机设置中,选中[网络适配器],之后在右边设置网络连接为[自定义:指定的虚拟网络] 然后设置同一网关即可.
- 万恶的ViewBag
作个记录,鼓捣了一晚上,他竟然把订单事情给我篡改了 ViewBag.orderNo="20150613202108844"; 页面上出来的竟然是20150613202108840 ...
- 将表里的数据批量生成INSERT语句的存储过程
有时候,我们需要将某个表里的数据全部导出来,迁移到另一个相同结构的库中,这里可以采取一个简便的方法,通过一个存储过程批量导出数据并生成SQL语句,非常方便.存储过程如下: )) as begin de ...