|
|
вернуться в форумWhat is a problem? (+) Maybe I don't understand the problem. I think, that problem is to find a maximum number of noncrossing intervals. But Sorting and this program too, cannot give ACCEPTED. Only WA :-) Andrey Popyk. popyk@ief.tup.km.ua ICQ# 88914410 VAR A:Array[1..30000] of integer; N,Ts,Te,Res,Curr,i:integer; BEGIN for i:=1 to 30000 do A[i]:=30001; readln(N); for i:=1 to N do begin readln(Ts,Te); if A[Ts]>Te then A[Ts]:=Te; end; Res:=0; Curr:=1; while Curr<=30000 do begin if A[Curr]=30001 then inc(Curr) else begin Curr:=A[Curr]+1; inc(Res) end; end; writeln(Res); END. Re: What is a problem? (+) > Res:=0; Curr:=1; > while Curr<=30000 do > begin > if A[Curr]=30001 then inc(Curr) > else begin Curr:=A[Curr]+1; inc(Res) end; > end; > writeln(Res); > END. For example, if you have A[1] = 29998 and A[29999] = 30000, Res will be equal 2 at end, but you may have a lot of segments betwen 1 and 29998. Try to do it in another way:). Email me if you still have problems. miguelangelhdz@hotmail.com Good Luck and thks for Euler algorithm :) Oh my God! :-) Thanks. Now I know where is my mistake. It is in my head :) |
|
|