比赛 |
20130725暑期B班1测 |
评测结果 |
AAAAAW |
题目名称 |
黑叔 |
最终得分 |
83 |
用户昵称 |
Fangel |
运行时间 |
0.029 s |
代码语言 |
Pascal |
内存使用 |
2.68 MiB |
提交时间 |
2012-07-18 11:21:36 |
显示代码纯文本
program p4;
var
a,b,c,d,t,n:longint;s:string;
q:char;ss:array[1..10000,1..2] of longint;
nam:array[1..10000] of string;
procedure kp(x,y:longint);
var
i,j,m,n:longint;
s,q:string;
begin
i:=x;j:=y;m:=ss[(i+j) div 2,1];s:=nam[(i+j) div 2];
repeat
while (ss[i,1]<m) or ((ss[i,1]=m) and (nam[i]<s) and (i<(x+y) div 2)) do inc(i);
while (ss[j,1]>m) or ((ss[j,1]=m) and (nam[i]>s) and (j>(x+y) div 2)) do dec(j);
if i<=j then begin
n:=ss[i,1];ss[i,1]:=ss[j,1];ss[j,1]:=n;
n:=ss[i,2];ss[i,2]:=ss[j,2];ss[j,2]:=n;
q:=nam[i];nam[i]:=nam[j];nam[j]:=q;
inc(i);dec(j);end;
until j<i;
if x<j then kp(x,j);
if i<y then kp(i,y);
end;
begin
assign(input,'hey.in');
reset(input);
assign(output,'hey.out');
rewrite(output);
read(n);
for a:=1 to n do
begin
read(ss[a,1]);
read(q);read(q);
s:='';
while q<>' ' do
begin
s:=s+q;
read(q);
end;
nam[a]:=s;
read(ss[a,2])
end;
kp(1,n);
b:=0;
for a:=1 to n do
begin
if ss[a,1]> b then begin writeln(nam[a],' went out at time ',ss[a,1]);b:=ss[a,1]+ss[a,2];end
else begin writeln(nam[a],' went out at time ',b);b:=b+ss[a,2];end;
end;
close(input);
close(output);
end.