1996: [Hnoi2010]chorus Chorus time limit:4 Sec Memory limit:64 MB
submit:1057 solved:681
[Submit] [Status] [Discuss] Descriptioninputoutputsample Input4
1701 1702 1703 1704Sample Output8HINT
Source
Solution: Meng Meng DP problem, in fact, and I first thought of the violence method is very close, basically is the memory of violence, and then into a circular form (hansbug: No effect of this thing is cool ^_^), and then just AC (PS: But the first time the memory of the violence WA dropped is what Ghost??? )
1/**************************************************************2Problem:19963 User:hansbug4 language:pascal5 result:accepted6Time:108Ms7Memory:8172KB8****************************************************************/9 Ten Constp=19650827; One var A I,j,k,l,m,n:longint; -C:Array[0..10000] ofLongint; -A:Array[0..1005,0..1005,1..2] ofLongint; the begin - READLN (n); - fori:=1 toN Do - begin + read (c[i]); -A[i,i,0]:=1; + End; A Readln; at fori:=n-1 Downto 1 Do - forj:=i+1 toN Do - begin -A[i,j,0]:=0; A[i,j,1]:=0; - ifc[i]<c[i+1] ThenInc (A[I,J,0],a[i+1J0]); - ifC[I]<C[J] ThenInc (A[I,J,0],a[i+1J1]); in ifC[j]>c[i] ThenInc (A[I,J,1],a[i,j-1,0]); - ifc[j]>c[j-1] ThenInc (A[I,J,1],a[i,j-1,1]); toA[i,j,0]:=a[i,j,0]MoDp; +A[i,j,1]:=a[i,j,1]MoDp; - End; theWriteln ((a[1N1]+a[1N0])MoDp); * Readln; $ End.
1996: [Hnoi2010]chorus Chorus Team