比赛 |
20130725暑期B班1测 |
评测结果 |
AAAAAA |
题目名称 |
黑叔 |
最终得分 |
100 |
用户昵称 |
李振文 |
运行时间 |
0.024 s |
代码语言 |
Pascal |
内存使用 |
3.94 MiB |
提交时间 |
2012-07-18 11:25:13 |
显示代码纯文本
- program a4;
- var
- a,b:array[1..15000]of longint;
- s:array[1..15000]of string;
- ss:char;
- i,n,j,l,k:longint;
- procedure f(i,j:integer);
- var
- x,y,z,zz:longint;
- zzz:string;
- begin
- x:=i;y:=j;z:=a[(i+j)div 2];
- repeat
- while a[x]<z do inc(x);
- while a[y]>z do dec(y);
- if y>=x then begin
- zz:=b[x];b[x]:=b[y];b[y]:=zz;
- zz:=a[x];a[x]:=a[y];a[y]:=zz;
- zzz:=s[x];s[x]:=s[y];s[y]:=zzz;
- inc(x);dec(y);end;
- until x>y;
- if x<j then f(x,j);
- if y>i then f(i,y);
- end;
- procedure ff(i,j:integer);
- var
- x,y:integer; zzzz:longint;
- sss,zzzzz:string;
- begin
- x:=i;y:=j;zzzzz:=s[(i+j)div 2];
- repeat
- while s[x]<zzzzz do inc(x);
- while s[y]>zzzzz do dec(y);
- if y>=x then begin
- zzzz:=b[x];b[x]:=b[y];b[y]:=zzzz;
- zzzz:=a[x];a[x]:=a[y];a[y]:=zzzz;
- sss:=s[x];s[x]:=s[y];s[y]:=sss;
- inc(x);dec(y);end;
- until x>y;
- if x<j then f(x,j);
- if y>i then f(i,y);
- end;
- begin
- assign(input,'hey.in');
- reset(input);
- assign(output,'hey.out');
- rewrite(output);
- readln(n); ;
- for i:=1 to n do begin
- read(a[i]);
- read(ss);
- read(ss);s[i]:=s[i]+ss;
- while ss<>' 'do begin
- read(ss);if ss<>' 'then s[i]:=s[i]+ss;end;
- readln(b[i]);
- end;
- f(1,n);i:=1;k:=0;
- while i<=n do begin
- if a[i]<>a[i+1]then begin
- if i=1 then begin writeln(s[i],' went out at time ',a[i]);
- k:=a[i]+b[i];inc(i);end else begin
- if k>=a[i] then begin writeln(s[i],' went out at time ',k);
- k:=k+b[i];inc(i);end else begin writeln(s[i],' went out at time ',a[i]);
- k:=a[i]+b[i];inc(i);end;end;end else
- begin j:=i+1;while a[i]=a[j] do inc(j);ff(i,j-1);
- if k<a[i]then k:=a[i];
- for l:=i to j-1 do begin
- writeln(s[l],' went out at time ',k);k:=k+b[l]end;
- i:=j;
- end;
- end;
- close(input);
- close(output);
- end.