记录编号 14665 评测结果 AAAAAAAAAA
题目名称 wordsa 最终得分 100
用户昵称 Gravatarlc 是否通过 通过
代码语言 Pascal 运行时间 0.014 s
提交时间 2009-11-02 20:50:20 内存使用 0.13 MiB
显示代码纯文本
program wordsa;
 const
   maxn = 5000;
 var
   n:           longint;
   sol:         longint;
   s:           string;
   ans:         array[1..2] of longint;
   minu:        array[1..maxn] of longint;
   year,month,day,hour,minute: array[1..2] of longint;




procedure sort(l,r:longint);
 var
   i,j,x,temp:  longint;
 begin
   i :=l; j :=r; x :=minu[(i+j) shr 1];
   repeat
     while minu[i] <x do inc(i);
     while minu[j] >x do dec(j);
     if i <=j then begin
        temp :=minu[i]; minu[i] :=minu[j]; minu[j] :=temp;
        inc(i);  dec(j);
        end;
   until i >j;
   if j >l then sort(l,j);
   if i <r then sort(i,r);
 end;


procedure init;
 var
   i:   longint;
 begin
   readln(n);
   for i :=1 to n do readln(minu[i]);
   sort(1,n);
 end;

function sumd(year,month:longint):longint;
 var
   t:   longint;
 begin
   case month of
     1: t :=31;
     2: if (month mod 400 = 0) or
           (month mod 100 <>0) and (month mod 4 = 0)
        then t :=29 else t :=28;
     3: t :=31;
     4: t :=30;
     5: t :=31;
     6: t :=30;
     7: t :=31;
     8: t :=31;
     9: t :=30;
     10:t :=31;
     11:t :=30;
     12:t :=31;
     end;
   exit(t);
 end;

function sumy(year:longint):longint;

 begin
   if (year mod 400 = 0)
   or (year mod 100 <>0) and (year mod 4 =0)
      then exit(366) else exit(365);
 end;



procedure release(var year,month,day,hour,minute:longint);
 var
   t:   string;
   k:   integer;
 begin
   k :=pos(' ',s); delete(s,k,1);
   t :=copy(s,1,4); val(t,year,k);
   t :=copy(s,6,2); val(t,month,k);
   t :=copy(s,9,2); val(t,day,k);
   t :=copy(s,12,2); val(t,hour,k);
   t :=copy(s,15,2); val(t,minute,k);
 end;


procedure main;
 var
   i,ty:   longint;

 begin
   for i :=1 to 2 do begin
       readln(s);
       release(year[i],month[i],day[i],hour[i],minute[i]);
       end;
   if year[2] - year[1] >100 then begin
      writeln(n); exit;
      end;
   for ty :=1 to 2 do begin
   ans[ty] :=ans[ty] + (59-minute[ty]);
   ans[ty] :=ans[ty] + (23-hour[ty])*60;
   ans[ty] :=ans[ty] + (sumd(year[ty],month[ty])-day[ty])*24*60;
   for i :=month[ty]+1 to 12 do inc(ans[ty],sumd(year[ty],i)*24*60);
   end;

   dec(ans[1],ans[2]);
   for i :=year[1]+1 to year[2] do inc(ans[1],sumy(i)*24*60);

   for i :=1 to n do begin
       if ans[1] <minu[i] then break;
       dec(ans[1],minu[i]);
       inc(sol);
       end;
   writeln(sol);
 end;



begin
  assign(input,'wordsa.in');  reset(input);
  assign(output,'wordsa.out'); rewrite(output);
  init;
  main;
  close(input);  close(output);
end.