记录编号 |
40680 |
评测结果 |
AAAAAW |
题目名称 |
[暑假培训2012] 黑叔 |
最终得分 |
83 |
用户昵称 |
bingo |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
0.138 s |
提交时间 |
2012-07-18 16:27:49 |
内存使用 |
5.13 MiB |
显示代码纯文本
var
i,j,k,l,n,st,et:longint;
time:longint;
s:string;
t1:string;
t,d:array[1..10000]of longint;
c,e:array[1..10000]of string;
f,g:text;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=t[(l+r) div 2];
repeat
while t[i]<x do
inc(i);
while x<t[j] do
dec(j);
if not(i>j) then
begin
y:=t[i];
t[i]:=t[j];
t[j]:=y;
k:=d[i];d[i]:=d[j];d[j]:=k;
s:=c[i];c[i]:=c[j];c[j]:=s;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
assign(f,'hey.in');
assign(g,'hey.out');
reset(f);
rewrite(g);
readln(f,n);
for i:=1 to n do
begin
readln(f,c[i]);
for j:=1 to length(c[i]) do
if c[i][j]=' 'then break;
val(copy(c[i],1,j-1),l,k);
t[i]:=l;
st:=j+1;
for j:=length(c[i]) downto 1 do
if c[i][j]=' 'then break;
et:=j-1;
val(copy(c[i],j+1,length(c[i])-j),l,k);
d[i]:=l;
e[i]:=copy(c[i],st,et-st+1);
end;
c:=e;
{===================================}
sort(1,n);
{===================================}
for i:=1 to n-1 do
for j:=i+1 to n do
begin
if (t[i]=t[j])and(c[i]>c[j]) then begin
s:=c[i];
c[i]:=c[j];
c[j]:=s;
end;
end;
for i:=1 to n do
begin
write(g,c[i],' went out at time ');
if time<t[i] then begin write(g,t[i]);time:=t[i]+d[i];end
else begin write(g,time);time:=time+d[i];end;
writeln(g);
end;
close(f);
close(g);
end.