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中可 ...
随机推荐
- swiper中提供的动画效果
目前就只有这些,大家也可以尝试自己写一些想要的效果.动手试试,才能清楚每个效果具体是怎么回事~ bounce:弹跳两下出来flash:闪烁两下pulse:脉冲形式出来rubberBand:橡皮圈形式弹 ...
- POJ 2481 Cows(树状数组)
Cows Time Limit: 3000MS Memory L ...
- day17算法
http://www.360doc.com/content/14/0804/11/1073512_399302715.shtml
- 为 C# 代码生成 API 文档(译)
原文地址:http://broadcast.oreilly.com/2010/09/build-html-documentation-for-y.html#comments Sandcastle 功能 ...
- (转) Deep Reinforcement Learning: Playing a Racing Game
Byte Tank Posts Archive Deep Reinforcement Learning: Playing a Racing Game OCT 6TH, 2016 Agent playi ...
- ajax请求后弹开新页面被浏览器拦截
window.open()我想应该很多人都不陌生吧,它可以实现除用a标签以外来实现打开新窗口! 最近开发项目用到时,却遇到了麻烦,本来好好的弹出窗口,结果被浏览器无情的给拦截了! 代码如下: $.ge ...
- unity, 由scriptableObject创建.asset
由继承自scriptableObject的类X创建.asset文件. 假设类X的定义为: [System.Serializable] public class X : ScriptableObject ...
- Storm Bolt接口
Bolt是Topology中数据处理的基本单元,也是Storm针对处理过程的编程单元.Topology中所有的处理都是在这些bolt中完成的. Bolt可以将数据项发送至多个数据流(Str ...
- [译] Python 3.5 协程究竟是个啥
转自:http://blog.rainy.im/2016/03/10/how-the-heck-does-async-await-work-in-python-3-5/ [译] Python 3.5 ...
- attr与prop
Jquery获取checkbox属性checked为undefined (-- ::)转载▼ 标签: js jquery checkbox checked undefined 分类: JQuery 使 ...