/ SB域 /

记录详情

Accepted

/usr/bin/ld.bfd: warning: /out/link.res contains output sections; did you forget -T?
# 状态 耗时 内存占用
#1 Accepted 0ms 256.0 KiB
#2 Accepted 1ms 256.0 KiB
#3 Accepted 1ms 256.0 KiB
#4 Accepted 2ms 256.0 KiB
#5 Accepted 2ms 256.0 KiB
#6 Accepted 2ms 256.0 KiB
#7 Accepted 2ms 256.0 KiB
#8 Accepted 2ms 256.0 KiB
#9 Accepted 23ms 512.0 KiB
#10 Accepted 35ms 996.0 KiB

代码

type rec=record
 s,e:longint;
end;
var n,i,ans,en:longint;
    a:array[0..200000]of rec;
procedure swap(var a,b:rec);
var t:rec;
begin
 t:=a; a:=b; b:=t;
end;
procedure qsort(l,r:longint);
var i,j,mide:longint;
begin
i:=l; j:=r;
 mide:=a[(l+r)div 2].e;
repeat
 while a[i].e<mide do inc(i);
 while a[j].e>mide do dec(j);
 if i<=j then begin
  swap(a[i],a[j]);
  inc(i);
  dec(j);
 end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
 readln(n);
 for i:=1 to n do readln(a[i].s,a[i].e);
 qsort(1,n);
// for i:=1 to n do writeln(a[i].s,' ',a[i].e);
 ans:=1;
 en:=a[1].e;
 for i:=2 to n do
  if a[i].s>en then begin
    en:=a[i].e;
    inc(ans);
  end;
 writeln(ans);
 close(input);close(output);
end.

信息

递交者
类型
递交
题目
【模板】最多不相交区间
题目数据
下载
语言
Pascal
递交时间
2017-08-22 16:04:46
评测时间
2017-08-22 16:04:46
评测机
分数
100
总耗时
75ms
峰值内存
996.0 KiB