比赛 |
20130725暑期B班1测 |
评测结果 |
AAWWWW |
题目名称 |
黑叔 |
最终得分 |
33 |
用户昵称 |
hjr1995 |
运行时间 |
0.034 s |
代码语言 |
Pascal |
内存使用 |
2.68 MiB |
提交时间 |
2012-07-18 11:26:58 |
显示代码纯文本
var
n,i,y,j:longint;e:char;g:string;
b,d:array[1..10001] of longint;
c:array[1..10001] of string;
procedure sort(l,r: longint);
var
w,z,x,y: longint;
begin
w:=l;
z:=r;
x:=b[(l+r) div 2];
repeat
while b[w]<x do
inc(w);
while x<b[z] do
dec(z);
if not(w>z) then
begin
y:=b[w];b[w]:=b[z];b[z]:=y;
y:=d[w];d[w]:=d[z];d[z]:=y;
g:=c[w];c[w]:=c[z];c[z]:=g;
inc(w);
z:=z-1;
end;
until w>z;
if l<z then
sort(l,z);
if i<r then
sort(w,r);
end;
begin
assign(input,'hey.in');reset(input);
assign(output,'hey.out');rewrite(output);
readln(n); fillchar(c,sizeof(c),0);
for i:=1 to n do
begin
read(b[i]);read(e);
repeat read(e);c[i]:=c[i]+e;until e=' ';
read(d[i]);
end;
sort(1,n);
for i:=1 to n-1 do
if b[i]=b[i+1] then
for j:=1 to length(c[i]) do
if ord(c[i][j])>ord(c[i+1][j]) then begin
y:=b[i];b[i]:=b[i+1];b[i+1]:=y;
y:=d[i];d[i]:=d[i+1];d[i+1]:=y;
g:=c[i];c[i]:=c[i+1];c[i+1]:=g;break;end;
writeln(c[1],' went out at time ',b[1]);
for i:=2 to n do
if b[i]<b[i-1]+d[i-1] then
begin
b[i]:=b[i-1]+d[i-1];
writeln(c[i],' went out at time ',b[i]);
end
else writeln(c[i],' went out at time ',b[i]);
close(input);close(output);
end.