/ SB域 /

记录详情

Accepted

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

代码

type rec=record
 jus,num,min,max:longint;
end;
var  n,m,i,p,ans,jus,j:longint;
     a,b:array[1..2500]of rec;
     u:array[1..2500]of boolean;
procedure qsorta(l,r:longint);
var t:rec;
   i,j,midmax,midmin:longint;
begin
 i:=l; j:=r;
 midmax:=a[(l+r)div 2].max;
 midmin:=a[(l+r)div 2].min;
 while i<j do
begin
 while (a[i].max<midmax)or((a[i].max=midmax)and(a[i].min<midmin)) do inc(i);
 while (a[j].max>midmax)or((a[j].max=midmax)and(a[j].min>midmin)) do dec(j);
 if i<=j then begin
   t:=a[i]; a[i]:=a[j]; a[j]:=t;
   inc(i);dec(j);
 end;
end;
if l<j then qsorta(l,j);
if r>i then qsorta(i,r);
end;
procedure qsortb(l,r:longint);
var i,j,mid:longint;
    t:rec;
begin
i:=l; j:=r;
mid:=b[(l+r)div 2].jus;
while i<j do
begin
 while b[i].jus<mid do inc(i);
 while b[j].jus>mid do dec(j);
 if i<=j then begin
   t:=b[i]; b[i]:=b[j]; b[j]:=t;
   inc(i);dec(j);
 end;
end;
if l<j then qsortb(l,j);
if r>i then qsortb(i,r);
end;
begin
 readln(n,m);
 for i:=1 to n do readln(a[i].min,a[i].max);
 for i:=1 to m do readln(b[i].jus,b[i].num);
 qsorta(1,n);
 qsortb(1,m);
 for i:=1 to m do begin
  jus:=b[i].jus;
  for j:=1 to n do
  if (jus<=a[j].max)and(jus>=a[j].min)and(b[i].num>0)
  then begin dec(b[i].num);
  a[j].min:=maxlongint;
  inc(ans);
  end;
 end;
 writeln(ans);
 close(input);
 close(output);
end.

信息

递交者
类型
递交
题目
正直糖豆
题目数据
下载
语言
Pascal
递交时间
2017-08-22 16:07:36
评测时间
2017-08-22 16:07:36
评测机
分数
100
总耗时
102ms
峰值内存
256.0 KiB