题目编号:290-破碎的项链 查看该题
状态: Unaccepted
测评机: Xeost[5]
得分: 90分
提交日期: 2009-5-26 11:14:00
有效耗时: 500毫秒
测试结果1: 测试结果错误.错误结果为:15 正确结果应为:11
测试结果2: 通过本测试点|有效耗时63ms
测试结果3: 通过本测试点|有效耗时47ms
测试结果4: 通过本测试点|有效耗时62ms
测试结果5: 通过本测试点|有效耗时62ms
测试结果6: 通过本测试点|有效耗时47ms
测试结果7: 通过本测试点|有效耗时47ms
测试结果8: 通过本测试点|有效耗时62ms
测试结果9: 通过本测试点|有效耗时47ms
测试结果10: 通过本测试点|有效耗时63ms
program beads;
var
i,n,best,m,j,b:longint;
temp:char;
a:array[1..100000]of char;
begin
readln(n);
for i:=0 to n-1 do
read(a[i]);
readln;
for i:=1 to n-1 do
if a[i]<>a[i-1] then break;
if i=n-1 then
begin
writeln(n);
close(output);
halt;
end;
i:=0;
j:=0;
b:=0;
best:=0;
while i<n do
begin
m:=b;
temp:=a[i];
while (i<2*n)and((temp=a[i mod n])or(a[i mod n]=’w’)) do
begin
i:=i+1;
m:=m+1;
if a[i mod n-1]=’w’ then inc(b) else b:=0;
end;
if m+j>best then best:=m+j;
j:=m-b;
end;
writeln(best);
end.