题目链接:

  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. Python数据类型(元组、列表、字符串、字典)

    元组tuple:不可修改的数据类型 ABC = ('a', 1, x, 'today') 列表list:可修改的数据类型 ABC = ['a', 1, x, 'today'] 字符串set: ABC ...

  2. Rouh set 入门知识3(上下近似集,正负域,边界域)

    在RS中,引入两个概念:一个是下近似集,另一个是上近似集.下近似集是指当一个集合不能利用有效的等价关系被恰当的分类是时,则可通过另外的集合来达到这个集合的近似.形式上,设X⊆U是任一子集,R是U上的等 ...

  3. angularjs ngTable -Custom filter template-calendar

    jsp页面: <script type="text/ng-template" id="path/to/your/filters/top-Date-One.html& ...

  4. ActionScript:Resampling PCM data

    使用基于flash的麦克风录音,如果想在获取完PCM采样数据后,通过Sound马上回放,必须经过resampling.(注意:如果录音是采用的44KHz的话,则不需要) 因此,需要as实现一个简便的函 ...

  5. basicAnimation移动图形

    目的:采用CABasicAnimation  点击屏幕上的点来是实现图像的位置移动  并且位置能够不反弹 难点:1 通过动画的KeyPath找到layer的属性 2 通过NSValue将点包装成对象 ...

  6. mongo db安装和php,python插件安装

    安装mongodb 1.下载,解压mongodb(下载解压目录为/opt) 在/opt目录下执行命令 wget fastdl.mongodb.org/linux/mongodb-linux-x86_6 ...

  7. login-登录

    <!DOCTYPE html><html><head><meta charset="UTF-8"><title>Inse ...

  8. extjs下拉框添加复选框

    给ComboBox组件配置listConfig 下拉框代码: var gyslxcm = Ext.create('Ext.form.field.ComboBox',{ id : 'gyslxcm', ...

  9. 在2015中使用V12版本的ReportView控件,会导致winform窗体不能正常打开

    在2015中使用V12版本的ReportView控件,会导致winform窗体不能正常打开,使用V10版本没问题,但2015中默认使用的就是V12版本,所以需要避免使用V12版本

  10. sphinx (coreseek)——3、区段查询 与 增量索引实例

    首先本文测试数据100多万的域名的wwwtitle 信息  检索数据: 首先建立临时表格: CREATE TABLE `sph_counter` ( `index_id` ) NOT NULL, `m ...