维护最新的R,遇到L时如果R出现过就更新答案。

#include <cstdio>
#include <algorithm>
using namespace std;
int n,x,r=-1,ans=-1;
char a[200005];
int main(){
    scanf("%d%s",&n,a);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(a[i]=='R')
            r=x;
        else if(r>-1)
            ans=(ans==-1)?(x-r)/2:min(ans,(x-r)/2);
    }
    printf("%d",ans);
}
  

 

相关文章:

  • 2022-12-23
  • 2021-06-07
  • 2022-02-02
  • 2022-12-23
  • 2021-11-04
  • 2021-08-10
  • 2021-10-03
猜你喜欢
  • 2021-05-22
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2021-11-28
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案