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中可 ...
随机推荐
- Linux下部署solrCloud
1. 准备工作 这里我只是把我的师兄教我的关于Solrcloud搭建的过程,以及需要注意的地方文档化了.感谢他教会了我很多. 1.机子IP 三台安装linux系统的机子的IP地址为: 172.24.1 ...
- Linux常用命令大全(share)
系统信息 arch 显示机器的处理器架构(1) uname -m 显示机器的处理器架构(2) uname -r 显示正在使用的内核版本 dmidecode -q 显示硬件系统部件 - (SMBIOS ...
- RestTemplate 请求url
1.get 请求 RestTemplate restTemplate = new RestTemplate(); String url = ""; JSONObject resul ...
- dedecms recommend 注入 exp
我看没人用python写过发过 所以我就发一下 喜欢用python的就用我这个吧 不喜欢的就用JAR那个或者PHP那个吧 #coding:GBK import re import urllib &q ...
- Sublime Text 2 安装Package Control和插件的两种方法
缘起 前几天系统刚刚还原了,重装完Sublime Text2再安装插件的时候可能是由于公司的网络环境的问题,各种报错,将解决方法记录下来.系统环境:Win7 x64 + Sublime Text2. ...
- MongoDB学习笔记四:索引
索引就是用来加速查询的.创建数据库索引就像确定如何组织书的索引一样.但是你的优势是知道今后做何种查询,以及哪些内容需要快速查找.比如:所有的查询都包括"date"键,那么很可能(至 ...
- input:-webkit-autofill 导致chrome的输入框背景颜色变成黄色
填写form表单时发现chrome的一个好坑啊! 当你之前有填写过表单,获取焦点时,input会有一个记录之前填写过的文本的下拉列表式的东东,就像这样:(抱歉丑了点,隐私问题打上了马赛克) 按理说,这 ...
- Sea.js学习2——Sea.js的API 快速参考
(7 个接口是最常用的) 一.seajs.config:用来对 Sea.js 进行配置. seajs.config({ // 设置路径,方便跨目录调用 paths: { 'arale': 'https ...
- [Linux] CentOS 加入开机启动
1.在/etc/init.d/目录下新建一个文件:autostart.sh #!/bin/sh #chkconfig: 2345 80 80 #description: auto start web ...
- 字符数组,字符指针,字符串常量,以及sizeof的一些总结
1.以字符串形式出现的,编译器都会为该字符串自动添加一个\0作为结尾 如在代码中写"abc",编译器帮你存储的是"abc\0". 2.数组的类型是由该数组所存放 ...