|
|
вернуться в форумDO LIKE ME Accepted HE MY PROGRAM memory 17 byte Послано Oleg 4 ноя 2002 19:30 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. Could you give me an explanation? I couldn't understand your program. Послано af 18 ноя 2002 10:37 Explanation here. 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. Re: Explanation here. 10 >>>><>>>< What about this test? Re: Explanation here. thanks |
|
|