题意:

有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. SAR指标(转)

    转自(https://zhidao.baidu.com/question/187156399.html) SAR指标又叫抛物线指标或停损转向操作点指标,其全称叫“Stop and Reverse,缩写 ...

  2. 网络I/O模型---同步异步阻塞非阻塞之惑

    网络I/O模型 人多了,就会有问题.web刚出现的时候,光顾的人很少.近年来网络应用规模逐渐扩大,应用的架构也需要随之改变.C10k的问题,让工程师们需要思考服务的性能与应用的并发能力. 网络应用需要 ...

  3. 删除SQL架构的用户

    ALTER AUTHORIZATION ON SCHEMA::db_owner TO db_owner

  4. 定时 回收 CentOS 系统 内存

    #!/bin/bash LIMIT= LOG_FILE="/data/logs/timing_dropcaches.log" #定时清理系统内存 #https://blog.csd ...

  5. css背景图宽度只适应,高度不变

    保证1920px的图片,在低分率率的电脑上也能正常显示,两边裁剪,中间居中,高度不变 <!DOCTYPE html> <html lang="en"> &l ...

  6. Java不区分大小写的CaseInsensitiveMap

    Java中对于键值对,我们习惯使用类HashMap,使用方式:Map<String, String> result=new HashMap<String,String>(); ...

  7. 【thinkphp5】安全建议:隐藏后台登录入口地址

    我们都知道后台   www.test.com/admin 是我们最常用的登录入口,方便的同时也留下了隐患,如果你刚好使用了 admin/ 这种账号密码的方式,会导致我们的后台完全暴露在外. 因此我们建 ...

  8. mysql按位的索引判断位的值

    DELIMITER $$ DROP FUNCTION IF EXISTS `value_of_bit_index`$$/*计算数字的某个位的值*/CREATE FUNCTION `value_of_b ...

  9. [原]获取openstack-pike安装包

    linux version: CentOS 7.5.1804 #进入仓库配置目录 cd /etc/yum.repo.d/ #批量重命名所有文件 for files in `ls *`; do mv $ ...

  10. Linux 的基本操作(系统的安装)

    操作系统的安装: 操作系统的安装 这次安装系统也是基于CentOS的安装.把光盘插入光驱,设置bios光驱启动.进入光盘的欢迎界面. 其中有两个选项,可以直接按回车,也可以在当前界面下输入 linux ...