SHARE
TWEET

Untitled

a guest May 21st, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program ar;
  2. var a:array[0..7] of integer;
  3. a1, a2, n, i, sum:integer;
  4. begin
  5. read(n);
  6. sum:=-1;
  7. readln(a1);
  8. for i:=2 to n do
  9. begin
  10. a[a1 mod 8]:=max(a[a1 mod 8],a1);
  11. readln(a2);
  12. if a2 mod 8<>0 then sum:=max(sum,a2+a[8-a2 mod 8])
  13. else sum:=max(sum,a2+a[0]);
  14. a1:=a2;
  15. end;
  16. writeln(sum);
  17. 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. OK, I Understand
 
Top