level 3
懦弱de狮子
楼主
var n,m,i,j,k,o:longint;
a:array['a'..'z']of longint;
b,s,f,h:array[0..21]of longint;
c,t:array[0..20]of string;
begin
readln(n,m);
for i:=1 to n do read(a[chr(i+96)]);
for i:=1 to m do read(b[i],c[i],t[i]);
for i:=1 to m do
begin
k:=pos(':',c[i]);
val(copy(t[i],1,k-1),s[i]);
val(copy(t[i],k+1,length(t[i])-k),f[i]);
end;
s[m+1]:=25;
for i:=1 to m do
begin
for j:=1 to length(c) do
begin
f[i]:=f[i]+a[c[i[j]]];
h[i]:=h[i]+a[c[i[j]]];
if f[i]>=60 then
begin
inc(s[i]);
f[i]:=f[i]-60;
end;
if s[i]>=24 then s[i]:=s[i]-24;
end;
if (s[i+1]<s[i])or(s[i+1]=s[i])and(f[i+1]<f[i]) then
begin
o:=0;
if f[i+1]>f[i] then o:=60;
f[i+1]:=f[i+1]+h[i]-f[i+1]+f[i]+o;
if f[i+1]>=60 then
begin
inc(s[i+1]);
f[i+1]:=f[i+1]-60;
end;
if s[i]>=24 then s[i]:=s[i]-24;
end;
end;
for i:=1 to m do
writeln(b[i],' ',s[i],':',f[i]);
end.
2017年01月01日 13点01分
1
a:array['a'..'z']of longint;
b,s,f,h:array[0..21]of longint;
c,t:array[0..20]of string;
begin
readln(n,m);
for i:=1 to n do read(a[chr(i+96)]);
for i:=1 to m do read(b[i],c[i],t[i]);
for i:=1 to m do
begin
k:=pos(':',c[i]);
val(copy(t[i],1,k-1),s[i]);
val(copy(t[i],k+1,length(t[i])-k),f[i]);
end;
s[m+1]:=25;
for i:=1 to m do
begin
for j:=1 to length(c) do
begin
f[i]:=f[i]+a[c[i[j]]];
h[i]:=h[i]+a[c[i[j]]];
if f[i]>=60 then
begin
inc(s[i]);
f[i]:=f[i]-60;
end;
if s[i]>=24 then s[i]:=s[i]-24;
end;
if (s[i+1]<s[i])or(s[i+1]=s[i])and(f[i+1]<f[i]) then
begin
o:=0;
if f[i+1]>f[i] then o:=60;
f[i+1]:=f[i+1]+h[i]-f[i+1]+f[i]+o;
if f[i+1]>=60 then
begin
inc(s[i+1]);
f[i+1]:=f[i+1]-60;
end;
if s[i]>=24 then s[i]:=s[i]-24;
end;
end;
for i:=1 to m do
writeln(b[i],' ',s[i],':',f[i]);
end.