CodeForces 699A Launch of Collider
枚举相邻两个$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的更多相关文章
- 【模拟】Codeforces 699A Launch of Collider
题目链接: http://codeforces.com/problemset/problem/699/A 题目大意: 给N个点,向左或向右运动,速度均为1,问最早什么时候有两个点相撞.无解输出-1 题 ...
- codeforces #363a Launch of Collider
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 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 ...
- 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 ...
- 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 ...
- 【CodeForces 699A】Launch of Collider
维护最新的R,遇到L时如果R出现过就更新答案. #include <cstdio> #include <algorithm> using namespace std; int ...
- CF699A Launch of Collider 题解
Content 有 \(n\) 辆车在一条数轴上,第 \(i\) 辆车在 \(a_i\) 上,每辆车要么向左,要么向右.开始,它们以 \(1\) 个单位每秒的速度在行驶.问你第一次撞车发生在第几秒的时 ...
- Codeforces Round #363 Div.2[111110]
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...
- Codeforces 699
Problem A Launch of Collider 题目大意 在x轴上有n个点,坐标均为偶数.每个点或向左移动或向右移动,每秒移动距离为1. 使所有点同时开始移动,求最早有点相遇的时间或无解. ...
随机推荐
- Python中Generators教程
转载至:https://www.bytelang.com/article/content/NQbmUaRIXyA= 要想创建一个iterator,必须实现一个有__iter__()和__next__( ...
- kubernetes1.4 基础篇:Learn Kubernetes 1.4 by 6 steps
本教程受Kubernetes官方最新更新的文档所触发,之所以没有做单纯的翻译是因为如下几个原因: Kubernetes官方此教程基于minikube,个人对minikube可能有偏见,觉得像玩具. M ...
- Product Management vs. Product Marketing
Posted by Marty Cagan on August 28, 2007 Tags: product management, product marketing, program manage ...
- hdu1042
#include"stdio.h" #include"stdlib.h" #include"string.h" #define N 1000 ...
- es5 数组
一. 数组申明 var a = new Array(5) 会生成一个长度为5 每个元素都是undifined的数组 var a = new Array(1,2,3) 跟 var a = [1,2,3 ...
- Maven之(一)Maven是什么
首先,Maven的正确发音是[ˈmevən],而不是"马瘟"以及其他什么瘟.Maven在美国是一个口语化的词语,代表专家.内行的意思,约等于北京话中的老炮儿. 一个对Maven比较 ...
- JVM性能调优监控工具jps、jstack、jmap、jhat、jstat使用详解
Jmap是一个可以输出所有内存中对象的工具,甚至可以将VM 中的heap,以二进制输出成文本.打印出某个java进程(使用pid)内存内的,所有'对象'的情况(如:产生那些对象,及其数量). 使用方法 ...
- html+css基础篇
2016年11月19号,计划把基础在看一下,听大神说好的东西就要多看几遍,知识是学来用的解决问题的,加油 接下来的是我在自学中的小笔记吧,每天都在保持几个小时的学习思考状态,由于要升本所以学前端的时间 ...
- git的入门使用操作
Git html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,addres ...
- 导入excel成一个list集合不支持大文件倒入(优化点在于分批分线程导入)
package com.bj58.saletb.news.utils; import org.apache.log4j.Logger; import org.apache.poi.ss.usermod ...