A. Launch of Collider (#363 Div.2)
A. Launch of Collidertime limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n particles will be launched inside it. All of them are located in a straight line and there can not be two or more particles located in the same point. The coordinates of the particles coincide with the distance in meters from the center of the collider, xi is the coordinate of the i-th particle and its position in the collider at the same time. All coordinates of particle positions are even integers.
You know the direction of each particle movement — it will move to the right or to the left after the collider's launch start. All particles begin to move simultaneously at the time of the collider's launch start. Each particle will move straight to the left or straight to the right with the constant speed of 1 meter per microsecond. The collider is big enough so particles can not leave it in the foreseeable time.
Write the program which finds the moment of the first collision of any two particles of the collider. In other words, find the number of microseconds before the first moment when any two particles are at the same point.
InputThe first line contains the positive integer n (1 ≤ n ≤ 200 000) — the number of particles.
The second line contains n symbols "L" and "R". If the i-th symbol equals "L", then the i-th particle will move to the left, otherwise the i-th symbol equals "R" and the i-th particle will move to the right.
The third line contains the sequence of pairwise distinct even integers x1, x2, ..., xn (0 ≤ xi ≤ 109) — the coordinates of particles in the order from the left to the right. It is guaranteed that the coordinates of particles are given in the increasing order.
OutputIn the first line print the only integer — the first moment (in microseconds) when two particles are at the same point and there will be an explosion.
Print the only integer -1, if the collision of particles doesn't happen.
Examplesinput4
RLRL
2 4 6 10output1input3
LLR
40 50 60output-1NoteIn the first sample case the first explosion will happen in 1 microsecond because the particles number 1 and 2 will simultaneously be at the same point with the coordinate 3.
In the second sample case there will be no explosion because there are no particles which will simultaneously be at the same point.
题意:
对撞机的任意地方有带方向的粒子,求最短相遇时间。
注意:粒子位置是成递增排列的,故要想最短必是相邻且左边粒子方向为右,右边粒子方向为左。
附AC代码:
#include<iostream>
#include<cstring>
using namespace std; const int INF=<<; int a[];
char b[];
int main(){
int n;
cin>>n;
cin>>b;
for(int i=;i<n;i++){
cin>>a[i];
}
int Min=INF;
for(int i=;i<n;i++){
if(Min>a[i]-a[i-]&&b[i]=='L'&&b[i-]=='R')
Min=a[i]-a[i-];
}
if(Min!=INF){
cout<<Min/<<endl;//对向相遇
}
else
cout<<"-1"<<endl;
return ;
}
A. Launch of Collider (#363 Div.2)的更多相关文章
- 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 ...
- Codeforces Round #363 Div.2[111110]
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位 ...
- Codeforces Round #363 (Div. 2) A、B、C
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- 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. 1 (A,B,C,D,E,F)
Codeforces Round 363 Div. 1 题目链接:## 点击打开链接 A. Vacations (1s, 256MB) 题目大意:给定连续 \(n\) 天,每天为如下四种状态之一: 不 ...
- Codeforces Round #363 (Div. 2) A
Description There will be a launch of a new, powerful and unusual collider very soon, which located ...
- Codeforces Round #363 (Div. 2) A 水
Description There will be a launch of a new, powerful and unusual collider very soon, which located ...
- Codeforces Round #363 (Div. 2)
A题 http://codeforces.com/problemset/problem/699/A 非常的水,两个相向而行,且间距最小的点,搜一遍就是答案了. #include <cstdio& ...
随机推荐
- MOS简单应用
高端功率开关驱动的原理非常简单,和低端功率开关驱动相对应,就是负载一端和开关管相连,另外一端直接接地.正常情况下,没有控制信号的时候,开关管不导通,负载中没有电流流过,即负载处于断电状态:反之,如果控 ...
- kubernetes 之QoS服务质量管理
系列目录 在kubernetes中,每个POD都有个QoS标记,通过这个Qos标记来对POD进行服务质量管理.QoS的英文全称为"Quality of Service",中文名为& ...
- php跳转
header("Location: http://bbs. lampbrother.net"); header("refresh:0;url=./login.php&qu ...
- Linux 系统监控.诊断工具之 IO wait
1. 常用组合方式有如下几种: 用vmstat.sar.iostat检测是否是CPU瓶颈 用free.vmstat检测是否是内存瓶颈 用iostat.dmesg 检测是否是磁盘I/O瓶颈 用netst ...
- CCNET自动构建之路
人永远追求效率(想偷懒),不想手动编译项目.发布站点于是产生了自动构建技术,.NET领域中CCNET是个不错的选择. 一路问题不少,记录一下. 准备环境 服务器上需要有iis.vs(与开发环境的版本一 ...
- iOS側拉栏抽屉效果Demo
源代码下载 側拉栏抽屉效果Demo 须要导入第三方的类库例如以下: 抽屉效果所需第三方类库下载 效果:既能够两側都实现抽屉效果也可仅仅实现左側栏或者右側栏的抽屉效果 waterm ...
- 我在开发第一个Swift App过程中学到的四件事
本文转载至 http://www.itjhwd.com/wzkfyigeswiftsjs/ 译者注:本文作者Greg Heo,这是他为讲授iOS 8 App Extensions视频教程而实际使用Sw ...
- 九度OJ 1127:简单密码 (翻译)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1218 解决:721 题目描述: Julius Caesar曾经使用过一种很简单的密码. 对于明文中的每个字符,将它用它字母表中后5位对应的 ...
- 九度OJ 1109:连通图 (最小生成树)
时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2783 解决:1432 题目描述: 给定一个无向图和其中的所有边,判断这个图是否所有顶点都是连通的. 输入: 每组数据的第一行是两个整数 n ...
- mongoose基于mongodb的数据评论设计
var CommentSchema = { data:{type: ObjectId, ref:'Data'}, //Data数据表,此处存数据id from:{type: ObjectId, ref ...