为什么这么耗时又超时?

编译通过...

├ 测试数据 01:答案正确... 0ms

├ 测试数据 02:答案正确... 0ms

├ 测试数据 03:答案正确... 0ms

├ 测试数据 04:答案正确... 0ms

├ 测试数据 05:答案正确... 0ms

├ 测试数据 06:答案正确... 789ms

├ 测试数据 07:运行超时...

├ 测试数据 08:运行超时...

├ 测试数据 09:运行超时...

├ 测试数据 10:运行超时...

---|---|---|---|---|---|---|---|-

Unaccepted 有效得分:60 有效耗时:789ms

var

w,n,m,i,j,s,k,p,q:integer;

a:array[1..30000]of integer;

begin

readln(w); readln(n); s:=0;

for i:=1 to n do readln(a[i]);

for i:=1 to n-1 do

for j:=i+1 to n do

if a[i]0)) and

(a[i]+a[j]>m) then begin m:=a[i]+a[j]; p:=i; q:=j; end;

if (p=0) and (q=0) and (a[i]>0) then begin inc(s); a[i]:=0; end;

if (p>0) or (q>0) then

begin

if (a[p]>0) and (a[q]>=0) then begin s:=s+1; a[p]:=0; a[q]:=0; end;

if (a[p]>0) and (a[q]

5 条评论

  • 1

信息

ID
1409
难度
4
分类
贪心 点击显示
标签
递交数
8082
已通过
3181
通过率
39%
被复制
25
上传者