第七个点WA!WA!WA!

P1167 刷题

夏色祭 @ 2017-04-07 20:25:50

const
  d:array[1..12]of longint=(31,28,31,30,31,30,31,31,30,31,30,31);
var
  a:array[0..5001]of longint;
  s:array[1..2]of ansistring; 
  sum:array[1..2]of int64;
  n,i,j,k,t,t1,ans,max:longint;
  x:ansistring;
procedure kp(l,r:longint);
var
  i,j,mid:longint;
  begin
    i:=l;
    j:=r;
    mid:=a[(l+r) >> 1];
    repeat
      while a[i]<mid do inc(i);
      while a[j]>mid do dec(j);
      if i<=j then 
        begin
          a[0]:=a[i];
          a[i]:=a[j];
          a[j]:=a[0];
          inc(i);
          dec(j);
        end;
    until i>j;
    if i<r then kp(i,r);
    if l<j then kp(l,j);
  end;
begin
  readln(n);
  for i:=1 to n do readln(a[i]);
  kp(1,n);
  for i:=1 to 2 do 
    begin
      readln(s[i]);
      x:=copy(s[i],1,pos('-',s[i])-1);
      delete(s[i],1,pos('-',s[i]));
      while (x[1]='0')and(length(x)>1) do delete(x,1,1);
      if x='' then x:='0';
      val(x,k);
      t:=k;
      for j:=1 to k-1 do 
        begin
          inc(sum[i],365);
          if (j mod 4=0)and(j mod 400=0) then inc(sum[i]); 
        end;
      //年
      x:=copy(s[i],1,pos('-',s[i])-1);
      delete(s[i],1,pos('-',s[i]));
      while (x[1]='0')and(length(x)>1) do delete(x,1,1);
      if x='' then x:='0';
      val(x,k);
      t1:=k;
      for j:=1 to k-1 do
        inc(sum[i],d[j]);
      if (t mod 4=0)and(t mod 400=0)and(t1>2) then inc(sum[i]);
      //月
      x:=copy(s[i],1,pos('-',s[i])-1);
      delete(s[i],1,pos('-',s[i]));
      while (x[1]='0')and(length(x)>1) do delete(x,1,1);
      if x='' then x:='0';
      val(x,k);
      inc(sum[i],k);
      //日
    end;
  ans:=(sum[2]-sum[1])*1440;
  for i:=1 to 2 do 
    begin
      sum[i]:=0;
      x:=copy(s[i],1,pos(':',s[i])-1);
      delete(s[i],1,pos(':',s[i]));
      while (x[1]='0')and(length(x)>1) do delete(x,1,1);
      if x='' then x:='0';
      val(x,k);
      inc(sum[i],k*60);
      //时
      x:=s[i];
      while (x[1]='0')and(length(x)>1) do delete(x,1,1);
      if x='' then x:='0';
      val(x,k);
      inc(sum[i],k);
      //分
    end;
  inc(ans,sum[2]-sum[1]);
  for i:=1 to n do 
    begin
      if ans<a[i] then break;
      inc(max);
      dec(ans,a[i]);
    end;
  write(max);
end.

by 夏色祭 @ 2017-04-07 20:34:14

已经好了,闰年判断错了


by 时光 @ 2017-10-29 21:23:53

@zykykyk ek啊你能不能先自己检查了再发讨论啊


|