求解,WA一个点。。。

测试数据 #0: Accepted, time = 0 ms, mem = 16464 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 16464 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 16468 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 16464 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 16464 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 16464 KiB, score = 10
测试数据 #6: Accepted, time = 31 ms, mem = 16464 KiB, score = 10
测试数据 #7: Accepted, time = 62 ms, mem = 16464 KiB, score = 10
测试数据 #8: WrongAnswer, time = 156 ms, mem = 16464 KiB, score = 0
测试数据 #9: Accepted, time = 250 ms, mem = 16464 KiB, score = 10
WrongAnswer, time = 499 ms, mem = 16468 KiB, score = 90
代码
pascal
var
n,p,i,j:longint;
max,now,ans:int64;
q:array[0..1000001]of record
num,qua:longint;
point:int64;
end;
begin
readln(n,p);
for i:=1 to n do
read(q[i].num);
q[1].qua:=q[1].num;
q[1].point:=q[1].num;
now:=q[1].num;
max:=q[1].num;
for i:=2 to n do
begin
now:=now+q[i].num;
if now>max then max:=now;
if now<0 then now:=0;
q[i].qua:=max mod p;
end;
max:=q[1].point+q[1].qua;
for i:=1 to n-1 do
begin
if q[i].qua+q[i].point>max
then
max:=q[i].qua+q[i].point;
q[i+1].point:=max;
end;
ans:=-maxlongint;
for i:=1 to n do
if ans<q[i].point
then
ans:=q[i].point;
writeln(ans mod p);
end.

0 条评论

目前还没有评论...

信息

ID
1850
难度
8
分类
(无)
标签
递交数
3348
已通过
392
通过率
12%
被复制
14
上传者