CodeForces - 799B-T-shirt buying (优先队列)
/*
Name:
Copyright:
Author:
Date: 2018/5/2 16:09:54
Description:优先队列
*/
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <queue>
using namespace std;
const int MAXN = ;
int price[MAXN];
struct tshirt{
int index, pri;
tshirt(int i){
this->index = i;
this->pri = price[i] ;
};
bool operator <(const tshirt& lpm) const {
return pri > lpm.pri;
}
};
int main()
{
int n;
while (scanf("%d", &n) != EOF) {
priority_queue<tshirt> lev[];
memset(price, , sizeof(price));
for (int i=; i<n; i++)
scanf("%d", &price[i]);
int level;
for (int i=; i<n; i++) {
scanf("%d", &level);
tshirt demo(i);
lev[level].push(demo);
}
for (int i=; i<n; i++) {
scanf("%d", &level);
tshirt demo(i);
lev[level].push(demo);
}
int num, fav;
scanf("%d", &num);
for (int i=; i<num; i++) {
scanf("%d", &fav);
if (lev[fav].empty() ){
cout<<-<<" ";
continue;
}
int value = ;
while (!lev[fav].empty() && !value) {
if (price[lev[fav].top().index] == -) {//去掉重复的
lev[fav].pop();
} else {
value = ;
cout<<lev[fav].top().pri<<" ";
price[lev[fav].top().index] = -;
lev[fav].pop();
}
}
if (!value){
cout<<-<<" ";
}
}
cout<<endl;
}
return ;
}
CodeForces - 799B-T-shirt buying (优先队列)的更多相关文章
- 【codeforces 799B】T-shirt buying
[题目链接]:http://codeforces.com/contest/799/problem/B [题意] 告诉你每个人喜欢的衣服的颜色; 然后告诉你每件衣服的正面和背面的颜色以及它的价格; 只要 ...
- Codeforces I. Producing Snow(优先队列)
题目描述: C. Producing Snow time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces GYM 100876 J - Buying roads 题解
Codeforces GYM 100876 J - Buying roads 题解 才不是因为有了图床来测试一下呢,哼( 题意 给你\(N\)个点,\(M\)条带权边的无向图,选出\(K\)条边,使得 ...
- T-shirt buying CodeForces - 799B (小根堆+STL)
题目链接 思路: 由于题目说了只有1,2,3,三种色号的衣服,然后开三个对应色号的小根堆, 我是根据pair<int,int> 创建了一个以价格小的优先的优先队列. pair中的另外一个i ...
- Codeforces 799B - T-shirt buying(STL)
题目链接:http://codeforces.com/problemset/problem/799/B 题目大意:有n件T恤,每件T体恤都分别有价格(每件衣服的价格不重复).前面的颜色.背部的颜色三种 ...
- CodeForces - 799B T-shirt buying 【贪心】
题目链接 http://codeforces.com/problemset/problem/799/B 题意 给出N件衣服 pi 表示 第i件衣服的价格 ai 表示 第i件衣服的前面的颜色 bi 表示 ...
- codeforces 725D . Contest Balloons(贪心+优先队列)
题目链接:codeforces 725D . Contest Balloons 先按气球数从大到小排序求出初始名次,并把名次排在第一队前面的队放入优先队列,按w-t-1值从小到大优先,然后依次给气球给 ...
- [ An Ac a Day ^_^ ] CodeForces 426C Sereja and Swaps 优先队列
题意: 给你一个有n个数的序列 取一个区间 这个区间内的数可以与区间外的值交换k次 问这样的区间最大值是多少 思路: 看数据是200 时间复杂度O(n*n) 应该可以暴力 顺便学习一下优先队列 枚举区 ...
- CodeForces 754D Fedor and coupons (优先队列)
题意:给定n个优惠券,每张都有一定的优惠区间,然后要选k张,保证k张共同的优惠区间最大. 析:先把所有的优惠券按左端点排序,然后维护一个容量为k的优先队列,每次更新优先队列中的最小值,和当前的右端点, ...
- Codeforces 1136D - Nastya Is Buying Lunch - [贪心+链表+map]
题目链接:https://codeforces.com/problemset/problem/1136/D 题意: 给出 $1 \sim n$ 的某个排列 $p$,再给出若干 $(x,y)$ 表示当序 ...
随机推荐
- Eclipse中tomcat设置
首先在Eclipse中新建一个tomcat的server,这里就不多说了. 新建完成后,双击新建的server,如下: 设置1:在Server Locations里,选择Use Tomcat inst ...
- spring项目报org.apache.tiles.definition.DefinitionsFactoryException: I/O错误原因及解决办法。
今天升级一个spring项目遇到如下错: HTTP Status 500 - Request processing failed; nested exception is org.apache.til ...
- Shell字符串操作
@1:子串削除 ${string#substring} 从$string 的开头位置截掉最短匹配的$substring. ${string##substring} 从$string 的开头位置截掉最长 ...
- input date 对 placeholder 的支持问题
正常情况下,text 的 input 会显示 placeholder 中的值,date 类型的 input 对其支持不好.实例代码如下: <input type="text" ...
- Boostrap常用组件英文名
dropdownlisttabsearchVertical TabSidebar with tabssidebarExpandable Panel ListFiltered Attendees Lis ...
- PAT 天梯赛 L1-029. 是不是太胖了 【水】
题目链接 https://www.patest.cn/contests/gplt/L1-029 AC代码 #include <iostream> #include <cstdio&g ...
- RHEL 5 安装gcc
rpm -ivh kernel-headers... rpm -ivh glibc-headers... rpm -ivh glibc-devel... rpm -ivh libgomp.. rpm ...
- 主攻ASP.NET MVC4.0之重生:上下滑动屏幕动态加载数据
@{ ViewBag.Title = "Index"; } <!DOCTYPE html> <html> <head> ...
- Cisco学习笔记
目录 1. 路由 1.1 静态路由 1.2 动态路由 2. 访问控制列表 2.1 标准访问控制列表 2.2 扩展访问控制列表 2.3 命名访问控制列表 3. VLAN 3.1 基础知识 3.2 配置实 ...
- Mysql 导出导入
MySQL数据库导出 以root登录vps,执行以下命令导出. 1./usr/local/mysql/bin/mysqldump -u root -p123456 zhumaohai > /ho ...