题目链接: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 ;
}

Uva12663的更多相关文章

随机推荐

  1. Intellij IDEA 2017 破解

    http://idea.lanyus.com/ https://www.cnblogs.com/wang1024/p/7485758.html

  2. 爪哇国新游记之十九----使用Stack检查数字表达式中括号的匹配性

    /** * 辅助类 * 用于记载字符和位置 * */ class CharPos{ char c; int pos; public CharPos(char c,int pos){ this.c=c; ...

  3. C++11 Lambda表达式简单解析

    C++11 新增了非常多特性,lambda 表达式是当中之中的一个.假设你想了解的 C++11 完整特性, 建议去http://www.open-std.org/看看新标准! 非常多语言都提供了 la ...

  4. mpvue + iview 实现跨平台开发(App,Wap,微信小程序)

    1.安装 vue-cli 脚手架 npm install --g vue-cli 2.创建项目 vue init mpvue/mpvue-quickstart test-wxapp cd test-w ...

  5. Asp.Net北大青鸟总结(五)-数据绑定控件

        在前面的博客我已经介绍了关于一个特殊控件也是我们经经常使用到的控件gridview的使用实现真假分页.这也是属于绑定控件的一种使用.那么我们接下来来介绍一下数据绑定这门技术吧!  一.数据绑定 ...

  6. HDU - 3038 How Many Answers Are Wrong (带权并查集)

    题意:n个数,m次询问,每次问区间a到b之间的和为s,问有几次冲突 思路:带权并查集的应用.[a, b]和为s,所以a-1与b就能够确定一次关系.通过计算与根的距离能够推断出询问的正确性 #inclu ...

  7. XYWi-Fi v2.0 简单的笔记本无线热点分享工具【Win】

    [软件名称]XYWi-Fi [版本号]v2.0 [适用系统]Windows 7/8/8.1/10 [功能特性]简单的笔记本无线热点分享工具 [下载地址]pan.baidu.com/s/1mgmOpJi ...

  8. lucene 索引中文档的属性建立与不建立带来的影响总结

    索引中文档的属性建立与不建立带来的影响总结   1.依据文档的某属性去查找索引的话,只会返回带有此属性(如果你对当前属性设定了条件,那么需要满足当前条件)的所有文档,没有建立此属性的文档是不会在返回结 ...

  9. 利用Python对文件进行批量重命名——以图片文件为例

    效果如下:0001号用户的第 i 张图片 代码: import os class ImageRename(): def __init__(self): self.path = 'C:/Users/lb ...

  10. APP IONIC3 angular4

    https://golb.hplar.ch/p/Hot-deploy-updates-with-the-cordova-hot-code-push-pluginnpm install @angular ...