• Sign Up
• Login
• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# qbmax

finalshare Oct 6th, 2015 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. Program QBMAX;
2. const
3.         FINP='';
4. var
5.         A:array [0..101,0..101] of shortint;
6.         F:array [0..101,0..101] of integer;
7.         m,n,i,j:byte;
8.         res:integer;
9.         fil:text;
10. function max(q,w,e:shortint):shortint;
11. begin
12. max:=q;
13. if max<w then max:=w;
14. if Max<e then max:=e;
15. end;
16. procedure init;
17. begin
18. for i:=0 to 101 do
19.         for j:=0 to 101 do
20.                 A[i,j]:=-101;
21. end;
22. procedure result;
23. begin
24. res:=F[1,n];
25. for I:=1 to m do
26.                 if res<F[i,n] then res:=F[i,n];
27. end;
28.
29. procedure optimize;
30. begin
31.         for i:=1 to m do
32.                 F[i,1]:=A[i,1];
33.
34.         for j:=2 to n do
35.                 for i:=1 to m do
36.                         begin
37.                                 F[i,j]:=max(F[i+1,j-1],F[i-1,j-1],F[i,J-1])+A[i,j];
38.                         end;
39. end;
40. begin
41.         assign(fil,FINP);
42.         reset(Fil);
43.         readln(fil,m,n);
44.         init;
45.
46.         for i:=1 to m do
47.                 begin
48.                                 for j:=1 to n do
49.                                 read(fil,A[i,j]);
50.                                 readln(fil);
51.                 end;
52.         optimize;
53.         result;
54.         writeln(res);
55. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top