ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1135. Recruits

var i,n,L,R:longint;
    ch:char;
begin
 readln(n);
 L:=0;
 R:=0;
 for i:=1 to n do
 begin
  read(ch);
  while not(ch in ['<','>']) do
   read(ch);
  case ch of
   '>':inc(R);
   '<':inc(L,R);
  end;
 end;
 writeln(L);
end.
Maigo Akisame (maigoakisame@yahoo.com.cn) Explanation here. [2] // Problem 1135. Recruits 5 Aug 2004 09:58
Denote by R the number of recruits at the right end of the queue. When you get a new '>', simply increase R by 1. If you receive a '<', the process is like this:

>>>>>< (Say R=5)
>>>><>
>>><>>
>><>>>
><>>>>
<>>>>>

Now you see, it takes exactly R turns to send the '<' to the left of the '>'s, and the number of the '>'s, or R, stays the same. So it's easy to understand the prog.
der_spider Re: Explanation here. // Problem 1135. Recruits 2 Mar 2008 03:49
10
>>>><>>><

What about this test?
Pegasus Re: Explanation here. // Problem 1135. Recruits 23 Nov 2012 11:06
thanks