题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=110383#problem/C

题目大意:有一些不同高度的桥,会涨几次水,水流初始高度为1,然后不停的涨潮落潮,求被淹没至少K次的桥的个数(一开始就在水中的桥不增加淹没次数)

题目思路:前缀和离散化

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define Min(x,y) (x<y?x:y)
#define Max(x,y) (x>y?x:y)
using namespace std;
#define gamma 0.5772156649015328606065120 //欧拉常数
#define MOD 100000007
#define inf 0x3f3f3f3f
#define N 100050
#define maxn 10001000
typedef long long LL;
typedef pair<int,int> PII; int n,m,k,a[N<<],res[N<<],cnt,b[N];
PII p[N]; int main()
{
int i,j,x,y,v,group,Case=;
while(scanf("%d%d%d",&n,&m,&k)!=EOF)
{
cnt=;
mst(res,);
for(i=; i<n; ++i)
scanf("%d\n",&b[i]);
p[].fi=;
a[cnt++]=;
for(i=; i<m; ++i)
{
scanf("%d%d",&p[i].se,&p[i+].fi);
++p[i].se;
++p[i+].fi;
a[cnt++]=p[i].se;
a[cnt++]=p[i+].fi;
}
--cnt;
stable_sort(a,a+cnt);
cnt=unique(a,a+cnt)-a;
for(i=; i<m; ++i)
{
int l=lower_bound(a,a+cnt,p[i].fi)-a;
int r=lower_bound(a,a+cnt,p[i].se)-a;
++res[l]; --res[r];
}
for(i=; i<cnt; ++i)
res[i]+=res[i-];
int ans=;
for(i=; i<n; ++i)
{
int pos=upper_bound(a,a+cnt,b[i])-a-;
if(res[pos]>=k) ++ans;
}
printf("Case %d: %d\n",++Case,ans);
}
return ;
}

最新文章

  1. Android 透明度百分比对应的 十六进制
  2. Paris Traceroute
  3. Thrift编译与验证 - python
  4. linux编译安装MySQL
  5. Web安全--XSS模版
  6. For 循环嵌套 0309
  7. TCP/IP详解学习笔记(3)-IP协议,ARP协议,RARP协议
  8. ruby文档
  9. [Cycle.js] From toy DOM Driver to real DOM Driver
  10. Java缓存
  11. Java7新特性
  12. MSIL实用指南-一维数组的操作
  13. git初始化本地项目及关联github远程库
  14. android studio Error:Execution failed for task &#39;:app:processDebugResources&#39;. &gt; com.android.ide.common.process.ProcessException: Failed to execute aapt
  15. css CSS常见布局解决方案
  16. Pytorch半精度浮点型网络训练问题
  17. Count and Say leetcode java
  18. 网页从url到网页展示到页面的流程
  19. BZOJ 1588: [HNOI2002]营业额统计 双向链表
  20. 记一次踩坑:使用ksoap-android时造成的okhttp依赖冲突问题

热门文章

  1. Charles 抓HTTPS包报以下错误:
  2. css - font-size
  3. .NET--百度百科
  4. 表单提交post和get方法区别
  5. 我对GFWed的一些自己的见解
  6. (四)Maven构建多模块项目
  7. strults2标签s:set的用法
  8. 设置U盘启动
  9. Android自定义圆形进度条,完成类似LOFTER效果
  10. event.returnvalue = false的使用