fork download
  1. const fi='';
  2. fo='';
  3. max=30000;
  4. var n,i:longint;
  5. t:array[1..60000] of integer;
  6. f:array[-1..60000] of longint;
  7. r:array[0..59999] of integer;
  8. w:text;
  9. function min(x,y:longint):longint;
  10. begin
  11. if x>y then min:=y else min:=x;
  12. end;
  13. procedure nhap;
  14. begin
  15. assign(w,fi);
  16. reset(w);
  17. readln(w,n);
  18. for i:=1 to n do read(w,t[i]);
  19. for i:=1 to n-1 do read(w,r[i]);
  20. close(w);
  21. end;
  22. procedure xuly;
  23. begin
  24. f[0]:=0; f[-1]:=0; r[0]:=max;
  25. for i:=1 to n do
  26. f[i]:=min(f[i-1]+t[i],f[i-2]+r[i-1]);
  27. end;
  28. procedure inkq;
  29. begin
  30. assign(w,fo);
  31. rewrite(w);
  32. writeln(w,f[n]);
  33. close(w);
  34. end;
  35. begin
  36. nhap;
  37. xuly;
  38. inkq;
  39. end.
Success #stdin #stdout 0s 808KB
stdin
Standard input is empty
stdout
0