枚举相邻两个$a[i]$与$a[i+1]$,如果$s[i]=R$并且$s[i+1]=L$,那么$i$和$i+1$会碰撞,更新答案。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c = getchar(); x = ;while(!isdigit(c)) c = getchar();
while(isdigit(c)) { x = x * + c - ''; c = getchar(); }
} const int maxn=;
int n,a[maxn];
char s[maxn]; int main()
{
scanf("%d",&n); scanf("%s",s);
for(int i=;i<n;i++) scanf("%d",&a[i]);
int ans=0x7FFFFFFF;
for(int i=;i<n-;i++)
if(s[i]=='R'&&s[i+]=='L') ans=min(ans,(a[i+]-a[i])/);
if(ans==0x7FFFFFFF) printf("-1\n");
else printf("%d\n",ans);
return ;
}

CodeForces 699A Launch of Collider的更多相关文章

  1. 【模拟】Codeforces 699A Launch of Collider

    题目链接: http://codeforces.com/problemset/problem/699/A 题目大意: 给N个点,向左或向右运动,速度均为1,问最早什么时候有两个点相撞.无解输出-1 题 ...

  2. codeforces #363a Launch of Collider

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  3. Codeforces Round #363 (Div. 2)->A. Launch of Collider

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  4. A. Launch of Collider Codeforces Round #363 (Div2)

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  5. A. Launch of Collider (#363 Div.2)

    A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  6. 【CodeForces 699A】Launch of Collider

    维护最新的R,遇到L时如果R出现过就更新答案. #include <cstdio> #include <algorithm> using namespace std; int ...

  7. CF699A Launch of Collider 题解

    Content 有 \(n\) 辆车在一条数轴上,第 \(i\) 辆车在 \(a_i\) 上,每辆车要么向左,要么向右.开始,它们以 \(1\) 个单位每秒的速度在行驶.问你第一次撞车发生在第几秒的时 ...

  8. Codeforces Round #363 Div.2[111110]

    好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...

  9. Codeforces 699

    Problem A Launch of Collider 题目大意 在x轴上有n个点,坐标均为偶数.每个点或向左移动或向右移动,每秒移动距离为1. 使所有点同时开始移动,求最早有点相遇的时间或无解. ...

随机推荐

  1. PHP关于foreach使用引用变量的坑

    写PHP好多年,但仍然会犯低级错误,今天遇到个 foreach中引用变量时的坑,PHP版本为 5.6.12 代码如下: <?php $arr = ['a', 'b', 'c', 'd', 'e' ...

  2. 近期unity ios接入的事情

    1,  在接入苹果内支付的时候,遇到一个很严重的问题,使用的公司的moni2来测试的,但是在测试的过程中发现每次调用oc的内支付代码后,总会先回调一个支付成功,然后弹出输入密码框,当点击取消后,再一次 ...

  3. 在SQL SERVER中查找用分隔符分隔的数据

    SELECT * FROM [DB_SCJC].[dbo].[tn_Manager] 其中, CHARINDEX({1},{2})中,{1}是要查找的字符,{2}是字典库.返回值为{1}在{2}中的位 ...

  4. ie7,IE8不支持document.getElmentsByClassName的问题

    if (!document.getElementsByClassName) { document.getElementsByClassName = function(className, elemen ...

  5. 关于在框架中使用curl的思考,以及,curl其实很好用

    初步猜想: 在接触到框架文档的第一阶段时,会觉得控制器调用模型就是一件很简单的事,tp中用D方法或者M方法来实例化模型,laravel中用命名空间来加载模型,CI中用$this->load-&g ...

  6. expressJS - 准备活动

    安装 nodeJS 1. package.json 2. CommonJS, AMD, ES6 3. Babel

  7. chrome浏览器如何在本地安装谷歌访问助手教程

    许多用户都需要使用谷歌的gmail,搜索.我们目前可以用谷歌访问助手解决google无法访问的问题.那么谷歌访问助手在chrome浏览器中如何安装和使用呢?今天我们详细介绍. 本地安装谷歌访问助手的步 ...

  8. [ An Ac a Day ^_^ ] [kuangbin带你飞]专题八 生成树 UVA 10600 ACM Contest and Blackout 最小生成树+次小生成树

    题意就是求最小生成树和次小生成树 #include<cstdio> #include<iostream> #include<algorithm> #include& ...

  9. SUSElinux的pam模块中$ISA变量的作用

    目的:限制非wheel用户切换至root 方法:vi /etc/pam.d/su文件,增加如下两行 auth sufficient /lib/security/pam_rootok.soauth re ...

  10. ACM北大学习

    在两周的学习下,对ACM竞赛有了更深入地了解.学习到了很多知识,见识到了很多高手,目光放得更长远了.最后的比赛,在100多个队伍中,获得第十八的名次,也不负我的学习.