Time Limits: 1000 ms Memory Limits: 262144 KB
Description
Output
Sample Output
Data Constraint
Hint
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| #include<bits/stdc++.h> using namespace std; struct A { long l,r; bool operator < (A w) const { return r>w.r; } }b[200010]; priority_queue<A>q; long n,m,a[200010],now=1,tot=0,ans=0; bool ss (A t1,A t2) { return t1.l<t2.l; } int main() { freopen("dream.in","r",stdin); freopen("dream.out","w",stdout); scanf("%ld %ld",&n,&m); for(int i=1;i<=n;i++) scanf("%ld %ld",&b[i].l,&b[i].r); for(int i=1;i<=m;i++) scanf("%ld",&a[i]); sort(b+1,b+n+1,ss); sort(a+1,a+m+1); for(int i=1;i<=m;i++) { while(b[now].l<=a[i]) { q.push(b[now]); now++;tot++; } if(!tot) continue; A tmp=q.top();q.pop(); tot--; while(tmp.r<a[i]&&tot) { tmp=q.top();q.pop();tot--; } if(tmp.r>=a[i]) ans++; } printf("%ld",ans); return 0; }
|
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 暗影小站! 注: 本博客暂不开设评论区,请使用邮件119548583@qq.com联系