# 12603 - Launch of Collider ## 題解: 要是RL這樣的排序,他們才會相遇,所以只要計算符合條件的時間。 ## Code: ```c=1 #include <stdio.h> #include <limits.h> #define min(a, b) (a < b ? a : b) #define N 200000 + 5 int n, x[N]; char dir[N]; int main(){ scanf("%d%s", &n, dir); for(int i=0; i<n; i++) scanf("%d", x + i); int ans = INT_MAX; for(int i=0; i<n-1; i++){ if(dir[i] == 'R' && dir[i+1] == 'L') ans = min(ans, (x[i+1] - x[i]) / 2); } printf("%d\n", ans == INT_MAX ? -1 : ans); return 0; } ``` ###### tags: `NTHUOJ`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up