题目链接:

  http://codeforces.com/problemset/problem/699/A

题目大意:

  给N个点,向左或向右运动,速度均为1,问最早什么时候有两个点相撞。无解输出-1

题目思路:

  【模拟】

  模拟一下,记录往左往右的位置即可。

 //
//by coolxxx
////<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<map>
#include<memory.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//#include<stdbool.h>
#include<math.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define abs(a) ((a)>0?(a):(-(a)))
#define lowbit(a) (a&(-a))
#define sqr(a) ((a)*(a))
#define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
#define mem(a,b) memset(a,b,sizeof(a))
#define eps (1e-8)
#define J 10
#define MAX 0x7f7f7f7f
#define PI 3.14159265358979323
#define N 200004
using namespace std;
typedef long long LL;
int cas,cass;
int n,m,lll,ans;
int a[N];
char s[N];
int main()
{
#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
// freopen("2.txt","w",stdout);
#endif
int i,j;
// for(scanf("%d",&cas);cas;cas--)
// for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
while(~scanf("%d",&n))
// while(~scanf("%d",&n))
{
ans=MAX;
scanf("%s",s+);
for(i=;i<=n;i++)
scanf("%d",&a[i]);
int l=-,r=-;
for(i=;i<=n;i++)
{
if(s[i]=='L')
{
l=a[i];
if(r!=-)ans=min((l-r)/,ans);
r=-;
}
else
r=a[i];
}
if(ans==MAX)puts("-1");
else printf("%d\n",ans);
}
return ;
}
/*
// //
*/

【模拟】Codeforces 699A Launch of Collider的更多相关文章

  1. CodeForces 699A Launch of Collider

    枚举相邻两个$a[i]$与$a[i+1]$,如果$s[i]=R$并且$s[i+1]=L$,那么$i$和$i+1$会碰撞,更新答案. #pragma comment(linker, "/STA ...

  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. 贪心+模拟 Codeforces Round #288 (Div. 2) C. Anya and Ghosts

    题目传送门 /* 贪心 + 模拟:首先,如果蜡烛的燃烧时间小于最少需要点燃的蜡烛数一定是-1(蜡烛是1秒点一支), num[g[i]]记录每个鬼访问时已点燃的蜡烛数,若不够,tmp为还需要的蜡烛数, ...

  8. 模拟 Codeforces Round #203 (Div. 2) C. Bombs

    题目地址:http://codeforces.com/problemset/problem/350/C /* 题意:机器人上下左右走路,把其他的机器人都干掉要几步,好吧我其实没读懂题目, 看着样例猜出 ...

  9. 模拟 Codeforces Round #249 (Div. 2) C. Cardiogram

    题目地址:http://codeforces.com/contest/435/problem/C /* 题意:给一组公式,一组数据,计算得到一系列的坐标点,画出折线图:) 模拟题:蛮恶心的,不过也简单 ...

随机推荐

  1. Unity3D 5.0简单的射线检测实现跳跃功能

    这里是一个简单的跳跃,5.0和其他版本貌似不一样,并且,再起跳功能做的不完全. 不过一个基本的思路在这里. 1.首先,射线检测,这里是利用一个空对象,放到主角对象的下面 2.然后调节射线的位置,在主角 ...

  2. sql根据'/'截取最后的字符串

    filpath字段值:/DataFile/UpLoad/Logo/NoPhoto.jpg select filpath,REVERSE((SUBSTRING(REVERSE(FilPath),0,CH ...

  3. requirejs+anjularjs+express框架

    1.目录 2.首页login.html如下: <!DOCTYPE html><html> <head> <title>登录界面</title> ...

  4. IOS学习--UIButton常用方法(20150122)

    // 1.创建一个自定义的按钮 UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; // 2.添加按钮 [self.view a ...

  5. 关于C#的编译与执行

    每一种编程语言,要想执行,就必须要转换为目标操作系统能够理解的语言才能执行,这种语言叫做本机代码(native code).C#也是一样的,也要做这样的转换,但是它不是一处到位的,在.NET Fram ...

  6. IIS部署.NET项目的有关事项_2015.07.02

    今天在做项目中的关于发送邮件的一些功能.在部署服务的时候遇到了一些奇葩的问题,基本上是和IIS有关的问题. 首先,项目是基于.NET Framework4.0 版本的,由于本人用的是一台新配置好的机器 ...

  7. php数组(array)输出三种形式

    $bbbb=array("11"=>"aaa","22"=>"bbb"); //只能输出值value不能输出 ...

  8. wordpress整站搬家总结

    去年图便宜,也没准备认真写博文,所以花了几百元钱买了个国内空间(域名已经备案).购买了以后,放了一个wordpress博客,没事的时候写写博文,但从没有抽出时间去写,文章的质量也不追求.一开始还可以, ...

  9. MySQL5.7.9免安装版配置方法

    1. 解压MySQL压缩包    将下载的MySQL压缩包解压到自定义目录下,我的解压目录是:    "D:\Program Files\mysql-5.7.9-win32"    ...

  10. ecshop 嵌入地图加载不了问题

    在ecshop 添加一个标识商家地理位置信息. 百度地图,加载不出来,查了下发现跟 js/transport.js 与 js/utils.js 两个文件有关在需要插入地图的地方去掉这两个文件的引用 地 ...