比赛 20091102 评测结果 WWWWWWWAWA
题目名称 wordsa 最终得分 20
用户昵称 .Xmz 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2009-11-02 12:08:16
显示代码纯文本
program xmz;
const
yue:array[1..12]of integer=(31,28,31,30,31,30,31,31,30,31,30,31);
var
f1,f2:text;
s,fen,t,tt,n,a,year1,year2,day1,day2,month1,month2,hour1,hour2,fen1,fen2,day:longint;
x:array[1..5000]of longint;
ch:char;
procedure px(l,r:longint);
var i,j,tmp,mid:longint;
begin
i:=l;j:=r;mid:=x[(l+r) shr 1];
repeat
while x[i]<mid do inc(i);
while mid>x[j] do dec(j);
if i<=j then
begin
tmp:=x[i];
x[i]:=x[j];
x[j]:=tmp;
inc(i);dec(j);
end;
until i>j;
if l<j then px(l,j);
if i<r then px(i,r);
end;
begin
 assign(f1,'wordsa.in');assign(f2,'wordsa.out');
 reset(f1);rewrite(f2);
 read(f1,n);
 for a:=1 to n do
  read(f1,x[a]);
  readln(f1);
  px(1,n);
 repeat
  read(f1,ch);
  if (ch>='0')and(ch<='9') then
   begin
    inc(tt);t:=ord(ch)-48;
    if tt=1 then inc(year1,t*1000);
    if tt=2 then inc(year1,t*100);
    if tt=3 then inc(year1,t*10);
    if tt=4 then inc(year1,t);
    if tt=5 then inc(month1,t*10);
    if tt=6 then inc(month1,t);
    if tt=7 then inc(day1,t*10);
    if tt=8 then inc(day1,t);
    if tt=9 then inc(hour1,t*10);
    if tt=10 then inc(hour1,t);
    if tt=11 then inc(fen1,t*10);
    if tt=12 then inc(fen1,t);
   end;
 until eoln(f1);
 tt:=0;
  repeat
  read(f1,ch);
  if (ch>='0')and(ch<='9') then
   begin
    inc(tt);t:=ord(ch)-48;
    if tt=1 then inc(year2,t*1000);
    if tt=2 then inc(year2,t*100);
    if tt=3 then inc(year2,t*10);
    if tt=4 then inc(year2,t);
    if tt=5 then inc(month2,t*10);
    if tt=6 then inc(month2,t);
    if tt=7 then inc(day2,t*10);
    if tt=8 then inc(day2,t);
    if tt=9 then inc(hour2,t*10);
    if tt=10 then inc(hour2,t);
    if tt=11 then inc(fen2,t*10);
    if tt=12 then inc(fen2,t);
   end;
 until eof(f1);
 if (year1<year2)or(month1<month2) then
 begin
  day:=yue[month1]-day1+1;
  if (((year1 mod 4=0)and(year1 mod 100<>0))or(year1 mod 400=0))and(month1=2) then inc(day);
  day1:=1;inc(month1);
  while (year1<year2)or(month1<month2) do
   begin
    day:=day+yue[month1];
    if (((year1 mod 4=0)and(year1 mod 100<>0))or(year1 mod 400=0))and(month1=2) then inc(day);
    if month1<12 then inc(month1) else begin month1:=1;inc(year1);end;
   end;
 end;
 inc(day,day2-day1);
 fen:=day*24+(hour2-hour1)*60+fen2-fen1;
 for a:=1 to n do
  if fen-x[a]>=0 then begin dec(fen,x[a]);inc(s);end
  else break;
  writeln(f2,s);
 close(f1);close(f2);
end.