Pascal 为什么70 分 我cena上测的是满分

P1093 [NOIP2007 普及组] 奖学金

黎明时空几何 @ 2016-08-26 09:44:34

var
  n,i,j,k:longint;
  a,b,c,d,e:array[1..10000] of longint;
begin
  readln(n);
  for i:=1 to n do begin
    read(b[i],c[i],d[i]);
    a[i]:=i;
    e[i]:=d[i]+b[i]+c[i];
  end;
  for i:=1 to n-1 do
    for j:=i+1 to n do
    if (e[i]<e[j]) or
       ((e[i]=e[j]) and (b[i]<b[j])) or
       ((e[i]=e[j]) and (b[i]=b[j]) and (a[i]>a[j])) then begin
         k:=e[i];
         e[i]:=e[j];
         e[j]:=k;
         k:=a[i];
         a[i]:=a[j];
         a[j]:=k;
      end;
  for i:=1 to 5 do writeln(a[i],' ',e[i]);
end.

by 姚文涛 @ 2016-08-26 11:30:14

cena上的数据可以是自己或别人造的,肯定很水,但是洛谷的数据肯定不是(会是些极端数据)

@黎明时空几何


by 黎明时空几何 @ 2016-08-26 14:34:25

请问大家能帮我找出些问题吗?谢谢!


by gt2004119 @ 2016-10-02 11:06:37


by qq872425710 @ 2016-10-15 10:02:10

最后b数组也要一起交换啊,不然会比较错误的


by chenshengwei @ 2016-12-13 19:43:20

  var  a,no,s:array[1..300]of longint;
n,i,j,x,y,t:longint;
begin
  read(n);
  for i:=1 to n do
  begin
  readln(a[i],x,y);
  s[i]:=a[i]+x+y;
  no[i]:=i;
  end;
  for i:=1 to n do
    for j:=i+1 to n do
    if (s[i]<s[j])or(s[i]=s[j])and(a[i]<a[j])or((s[i]=s[j])and(a[i]<a[j])or(no[i]>no[j])) then
    begin
      t:=s[i];s[i]:=s[j];s[j]:=t;
      t:=a[i];a[i]:=a[j];a[j]:=t;
      t:=no[i];no[i]:=no[j];no[j]:=t;
    end;
   for i:=1 to 5 do   writeln(no[i],' ',s[i]);
end. 
发答案

|