题意:

有n排座位,每排有两个座位,每排座位的宽度都不一样。

有2 * n个人要上车,如果是内向的人,那么它会选择一排两个都是空位并且宽度最小的一排去坐;

如果是外向的人,会选择一排座位已经有人坐的,并且宽度最大的一排。

输入数据保证外向的人一定可以找到合适的位置。

问每一个人坐的排数是多少。

思路:

用map存每个长度代表的座位,两个set存没有被占in的和已经被占ex的。

如果是内向的人,每次从没有被占的选择最小的,插入已经被占的,然后从没有被占中擦除;

如果是外向的人,直接从被占的选择一个最大的,再擦除。

感觉就是考察STL的运用。

代码:

 #include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
const int N = 4e5 + ;
set<int> ex,in;
map<int,int> mmp;
char s[N];
int main()
{
int n;
scanf("%d",&n);
for (int i = ;i <= n;i++)
{
int x;
scanf("%d",&x);
in.insert(x);
mmp[x] = i;
}
scanf("%s",s);
for (int i = ;i < * n;i++)
{
if (s[i] == '')
{
auto it = in.begin();
printf("%d ",mmp[*it]);
ex.insert(*it);
in.erase(*it);
}
else
{
auto it = ex.rbegin();
printf("%d ",mmp[*it]);
ex.erase(*it);
}
}
return ;
}

codeforces 982B Bus of Characters的更多相关文章

  1. Codeforces Round #484 (Div. 2) B. Bus of Characters(STL+贪心)982B

    原博主:https://blog.csdn.net/amovement/article/details/80358962 B. Bus of Characters time limit per tes ...

  2. Bus of Characters(栈和队列)

    In the Bus of Characters there are nn rows of seat, each having 22 seats. The width of both seats in ...

  3. Codeforces 982 B. Bus of Characters(模拟一个栈)

    解题思路: 排序之后模拟一个栈(也可以用真的栈),时间复杂度o(n). 代码: #include <bits/stdc++.h> using namespace std; typedef ...

  4. 【模拟】Codeforces 711A Bus to Udayland

    题目链接: http://codeforces.com/problemset/problem/711/A 题目大意: N个字符串,每个字符串5位,找到第一个出现两个OO的并改成++输出YES和改后字符 ...

  5. [Codeforces 864C]Bus

    Description A bus moves along the coordinate line Ox from the point x = 0 to the point x = a. After ...

  6. Codeforces G. Bus Number(dfs排列)

    题目描述: Bus Number time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  7. CodeForces 711A Bus to Udayland (水题)

    题意:给定一个n*4的矩阵,然后O表示空座位,X表示已经有人了,问你是不能找到一对相邻的座位,都是空的,并且前两个是一对,后两个是一对. 析:直接暴力找就行. 代码如下: #pragma commen ...

  8. CodeForces 711A Bus to Udayland

    简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #inclu ...

  9. Codeforces 991E. Bus Number (DFS+排列组合)

    解题思路 将每个数字出现的次数存在一个数组num[]中(与顺序无关). 将出现过的数字i从1到num[i]遍历.(i from 0 to 9) 得到要使用的数字次数数组a[]. 对于每一种a使用排列组 ...

随机推荐

  1. dubbo系列二:dubbo常用功能总结

    准备工作: (1)启动zookeeper作为dubbo的注册中心 (2)新建一个maven的生产者web工程dubbo-provider-web和一个maven的消费者web工程dubbo-consu ...

  2. GDC2017【神秘海域 4】中所使用的顶点着色器技术

    原文链接 http://game.watch.impress.co.jp/docs/news/1047802.html   会場:San Francisco Moscone Convention Ce ...

  3. centos系统安装rar解压工具unar

    centOS上不支持rar解压,需要额外安装软件,收费版是unrar,免费版是unar unar在centOS上安装需要源码编译,下面是安装方法: 1.安装依赖 yum install gnustep ...

  4. 用 wait-notify 写一段代码来解决生产者-消费者问题

    在同步块中调用 wait() 和 notify()方法,如果阻塞,通过循环来测试等待条件.请参考答案中的示例代码. [生产者] import java.util.Vector; import java ...

  5. Oracle 行列转置

    两种简单的行列转置 1.固定列数的行列转换如student   subject    grade--------- ---------- --------student1  语文       80st ...

  6. 后渗透神器Empire的简单使用

    1.安装 1.1.系统环境: Debian系Linux:例如Ubuntu和Kali(本文使用Kali作为环境) 1.2.安装命令: 安装最后需要输入用户名.密码 wget https://raw.gi ...

  7. Solve Error: Unhandled exception at 0x00905a4d in xxx.exe: 0xC0000005: Access violation.

    在使用Visual Studio进行项目开发的时候,有时候会遇到下面这个错误: Unhandled exception at 0x00905a4d in xxx.exe: 0xC0000005: Ac ...

  8. css hsla和rgba的区别

    在CSS3里可以使用RGBA和HSLA两种色彩模式,都可以用来在设置颜色的同时也可以设置它的透明度.RGBA指的是“红色.绿色.蓝色和Alpha透明度”(Red-Green-Blue-Alpha),而 ...

  9. sql数据库光标变成黑快怎么回事?

    可能是因为你按到了insert键啦,你再按一下insert键应该就可以啦. 光标变成块状说明当前是覆盖模式.光标变成竖条状说明当前是插入模式.

  10. 2018-2019-2 网络对抗技术 20165318 Exp2 后门原理与实践

    2018-2019-2 网络对抗技术 20165318 Exp2 后门原理与实践 后门的基本概念及基础问题回答 常用后门工具 netcat Win获得Linux Shell Linux获得Win Sh ...