|
|
вернуться в форумtime limit exceeded Послано IT 7 мар 2016 18:17 var A:array[1..4000] of integer; B:array[1..4000] of integer; C:array[1..4000] of integer; q,w,e,r,t,y,i,o,p,s:integer; begin read(q); for r:=1 to q do read(A[r]); read(w); for t:=1 to w do read(B[t]); read(e); for y:=1 to e do read(C[y]); for i:=1 to q do begin for o:=1 to w do for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s); end; write(s); end. Re: time limit exceeded You should make variables like i1 ,i2, i3 but not q,w,e.r,t,y you know? So your program isn't clear. And about your timelimi.... : put here for o:=1 to w do >>> for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s); this: if A[i]=B[o] then begin for p:=1 to e do if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end; and...think about what you can delete from this: if (A[i]=B[o]) and (A[i]=C[p]) then inc(s);end; |
|
|