比赛 NOIP2008集训模拟4 评测结果 C
题目名称 彩色穿孔卡片 最终得分 0
用户昵称 Hamster 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-13 11:15:59
显示代码纯文本
program punch;
var
 n:integer;
 a,b,s:array[1..10000] of longint;
 z:array[1..100000000] of longint;
 m,i,j:longint;
 fin,fout:text;

procedure init;
var
 i,j:longint;
begin
 readln(fin,n);
 for i:=1 to n do
 readln(fin,a[i],b[i]);
 fillchar(s,sizeof(s),0);
 fillchar(z,sizeof(z),0);
end;

 
end;
begin
 assign(fin,'punch.in');
 assign(fout,'punch.out');
 reset(fin);
 rewrite(fout);
 
 init;
 m:=0;
 for i:=1 to n do
 begin
 for j:=a[i]+1 to b[i] do
 if z[j]<>i then
 begin
   if z[j]>0 then
   begin
     dec(s[z[j]]);
     if s[z[j]]=0 then dec(m);
   end;
   z[j]:=i;
   if s[i]=0 then inc(m);
   inc(s[i]);
 end;
 end;
 
 write(fout,m);
 
 close(fin);
 close(fout);
end.