Codeforces Launch of Collider
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define high 200010
#define inf 2147483647
#define sf scanf
#define pf printf
struct my
{
char ch;
LL v;
};
my ar[high];
LL br[high];
int main()
{
LL n;
while(~sf("%lld", &n))
{
getchar();
LL i=0 , j=0 , x;
char dir;
for(j=1; j<=n; j++)
{
sf("%c", &dir);
i++;
ar[i].ch = dir;
}
i=0;
//getchar();
for(j=1; j<=n; j++)
{
sf("%lld", &x);
i++;
ar[i].v=x;
}
//for(i=0; i<n; i++) cout << ar[i].ch << " " << ar[i].v << "\n";
LL k=1 , cnt = inf;
for(i=1; i<=n-1; i++)
{
if(ar[i].ch == 'R' and ar[i+1].ch == 'L')
{
cnt = min(cnt, (abs(ar[i].v - ar[i+1].v)) / 2);
}
}
if(cnt == inf)
{
cnt = -1;
}
pf("%lld\n", cnt);
}
return 0;
}
using namespace std;
typedef long long LL;
#define high 200010
#define inf 2147483647
#define sf scanf
#define pf printf
struct my
{
char ch;
LL v;
};
my ar[high];
LL br[high];
int main()
{
LL n;
while(~sf("%lld", &n))
{
getchar();
LL i=0 , j=0 , x;
char dir;
for(j=1; j<=n; j++)
{
sf("%c", &dir);
i++;
ar[i].ch = dir;
}
i=0;
//getchar();
for(j=1; j<=n; j++)
{
sf("%lld", &x);
i++;
ar[i].v=x;
}
//for(i=0; i<n; i++) cout << ar[i].ch << " " << ar[i].v << "\n";
LL k=1 , cnt = inf;
for(i=1; i<=n-1; i++)
{
if(ar[i].ch == 'R' and ar[i+1].ch == 'L')
{
cnt = min(cnt, (abs(ar[i].v - ar[i+1].v)) / 2);
}
}
if(cnt == inf)
{
cnt = -1;
}
pf("%lld\n", cnt);
}
return 0;
}
Comments
Post a Comment