比赛 |
20091102 |
评测结果 |
AAAWWAAAAA |
题目名称 |
wordsa |
最终得分 |
80 |
用户昵称 |
ybh |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-02 13:17:19 |
显示代码纯文本
program wordsa;
const
t1:array[0..12]of integer=
(0,31,59,90,120,151,181,212,243,273,304,334,365);
t2:array[0..12]of integer=
(0,31,60,91,121,152,182,213,244,274,305,335,366);
var
a:array[0..5001] of longint;
st:array[1..2] of string;
yard,month,day,hour,minute,tday,tminute:array[1..2] of longint;
n,i,j,ans:longint;
time,he:int64;
code:integer;
bool:boolean;
procedure sort(l,r:longint);
var
i,j,x,temp:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while a[j]>x do
dec(j);
if i<=j then
begin
temp:=a[i];
a[i]:=a[j];
a[j]:=temp;
inc(i);
dec(j)
end
until i>j;
if i<r then sort(i,r);
if l<j then sort(l,j)
end;
begin
assign(input,'wordsa.in');
reset(input);
assign(output,'wordsa.out');
rewrite(output);
readln(n);
for i:=1 to n do
readln(a[i]);
sort(1,n);
for i:=1 to 2 do
begin
readln(st[i]);
st[i]:=st[i]+'#';
for j:=1 to 5 do
if st[i,j+1]='-' then
begin
val(copy(st[i],1,j),yard[i],code);
delete(st[i],1,j+1);
break
end;
for j:=1 to 5 do
if st[i,j+1]='-' then
begin
val(copy(st[i],1,j),month[i],code);
delete(st[i],1,j+1);
break
end;
for j:=1 to 5 do
if st[i,j+1]='-' then
begin
val(copy(st[i],1,j),day[i],code);
delete(st[i],1,j+1);
break
end;
for j:=1 to 5 do
if st[i,j+1]=':' then
begin
val(copy(st[i],1,j),hour[i],code);
delete(st[i],1,j+1);
break
end;
for j:=1 to 5 do
if st[i,j+1]='#' then
begin
val(copy(st[i],1,j),minute[i],code);
break
end;
end;
for i:=1 to 2 do
begin
if ((yard[i] mod 100=0) and (yard[i] mod 400=0)) or ((yard[i] mod 100<>0) and (yard[i] mod 4=0))
then tday[i]:=t2[month[i]]+day[i]
else tday[i]:=t1[month[i]]+day[i];
tminute[i]:=hour[i]*60+minute[i]
end;
time:=0;
if (yard[1]=yard[2]) and (month[1]=month[2]) and (day[1]=day[2]) then
begin
time:=tminute[2]-tminute[1]
end
else
begin
if yard[1]=yard[2] then
begin
time:=(tday[2]-tday[1]-1)*60*24;
time:=time+60*24-tminute[1];
time:=time+tminute[2]
end
else
begin
for i:=yard[1]+1 to yard[2]-1 do
if ((i mod 100=0) and (i mod 400=0)) or ((i mod 100<>0) and (i mod 4=0))
then time:=time+527040
else time:=time+525600;
if ((yard[1] mod 100=0) and (yard[1] mod 400=0)) or ((yard[1] mod 100<>0) and (yard[1] mod 4=0))
then time:=time+527040-(tday[1]-1)*60*24-tminute[1]
else time:=time+525600-(tday[1]-1)*60*24-tminute[1];
time:=time+(tday[2]-1)*24*60+tminute[2]
end
end;
he:=0;
bool:=true;
for i:=1 to n do
if he+a[i]>time then
begin
ans:=i-1;
bool:=false;
break
end
else
begin
he:=he+a[i]
end;
if bool
then writeln(n)
else writeln(ans);
close(input);
close(output)
end.