zoukankan      html  css  js  c++  java
  • Dispute (dispute)

    Description


    The (n) people line up in a line from left to right, and everyone faces either to the left or to the right.
    The relationship between these (n) individuals is not very harmonious, so if two adjacent people are standing face to face (the one on the left is facing the right and the person on the right is facing the left), then they will have a dispute, one of them Will drive another person out of the team.
    In each dispute, any two situations (the person on the left or the person on the right are kicked out of the team) may occur; and for multiple disputes that exist at the same time, they will occur in any possible order, but there will be no Two disputes occurred at the same time.
    Request the minimum possible value of the number of people left in the team when the team is stable, that is, when any two people will not have a dispute.

    Format


    Input

    The first line contains a positive integer (n), which represents the number of people.
    The second line contains a string of length (n), from left to right indicating the direction of each person, where "L" means facing left and "R" means facing right.

    Output

    Output an integer per line, which is the smallest possible value of the remaining number of people.

    Sample


    Input

    6
    LRRLRL
    

    Output

    2
    

    Sample Explanation

    One possible way to reach 2 people is LRRLRLLRLRLLRRLLRLLR.

    Hint


    Test point number (n) Agreement
    (1,2,3) (leq 10^6) None
    (4,5,6) (leq 3) All face the same
    (7,8,9,10) (leq 10^6) None

    Sample Code


    Code is not available!
    
  • 相关阅读:
    难以实践敏捷:估算
    使用AsyncEnumerator简化异步操作
    ESXi 入门配置
    学习模式,不如先了解问题
    我应该用哪种虚拟机?(一)
    在2003上实现Custom Task Pane
    我应该用哪种虚拟机?(终)
    我应该用哪种虚拟机?(二)
    正则表达式周二挑战赛 第十二周
    [译]Node中的ES6特性
  • 原文地址:https://www.cnblogs.com/jiupinzhimaguan/p/13817597.html
Copyright © 2011-2022 走看看