luyencode / comments

Server lưu trữ bình luận trên Luyện Code
https://luyencode.net
6 stars 3 forks source link

https://oj.luyencode.net/problem/COWRUN #894

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Chi tiết bài tập - Luyện Code Online

https://oj.luyencode.net/problem/COWRUN

anle12345 commented 1 year ago

testcase 2 là gì vậy , ad ?

anle12345 commented 1 year ago

Đây là lời giải của mình đã AC. Nếu bạn đã cố gắng mà chưa làm được thì có thể tham khảo lời giải của mình.

Xem code AC

uses crt; var i,n,j,m,x:longint; a:array[0..10000] of longint; f1,f2:array[0..10000,0..500] of longint; function max(a,b:longint):longint; begin if a>b then exit(a); exit(b); end; begin readln(n,m); for i:=1 to n do read(a[i]); for i:=1 to m do f1[0,i]:=-maxlongint div 3; f1[0,m]:=0; for i:=1 to n do begin for j:=0 to m-1 do begin f1[i,j]:=f1[i-1,j+1]+a[i]; f2[i,j]:=max(f2[i-1,j-1],f1[i-1,j-1]); end; f1[i,m]:=max(f1[i-1,m],max(f2[i-1,m-1],f1[i-1,m-1])); end; x:=0; for i:=1 to n do x:=max(x,f1[i,m]);// <0 khong phai <=0 clrscr; writeln(x); readln; readln; end.

anle12345 commented 1 year ago

bò Bessie không nhất thiết phải chạy , nghỉ liên tục để tăng , giảm thể lực liên tục . Mà khi thể lực đủ thì nó có thể nghỉ thoải mái , thể lực không tăng.