Uva12663
题目链接: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的更多相关文章
随机推荐
- Unity3D研究院之IOS本地消息通知LocalNotification的使用(六十七)
http://www.xuanyusong.com/archives/2632 现在的游戏里一般都会有本地消息,比如每天定时12点或者下午6点告诉玩家进入游戏领取体力.这种东西没必要服务器去推送 ...
- MonoDevelop 的一些设置
原地址:http://hi.baidu.com/next2_me MonoDevelop保存跳到顶部 Saving in MonoDevelop goes to the top line. MonoD ...
- JAVA自带监控工具的介绍
转:http://www.alidw.com/?p=326 相信部分同学可能还是不太了解或者很少使用,这些监控工具是jdk5.0以上才会有的,有部分是liunx特有的. 了解这些工具再做压力测试和调优 ...
- Android开发SDK接入机智云,智能家居实现APP远程控制多设备
代码地址如下:http://www.demodashi.com/demo/12847.html 一.前言. 此框架只用了一周星期做了出来,因为对机智云的框架比较熟悉了 !期间SDK初始化出了问题,去咨 ...
- c#枚举的描述和值
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; usin ...
- ios 中尝试多次请求
-(void)tryRun { tryTimes++; id obj = [ASODataManager getAppleAccount]; if (obj) { __block FirstViewC ...
- webpack打包vue2.0项目时必现问题(转载)
原文地址:http://www.imooc.com/article/17868 [Vue warn]: You are using the runtime-only build of Vue wher ...
- 关于POI 中单元格背景色设置(转)
关于POI 中单元格背景色设置(转) csdn 中找到了用Apache POI 实现单元格背景色的小例子 我用了JDK6 + POI 3.17 ,调试中报错 最终将 CellStyle.SOLID ...
- Linux在本地使用yum安装软件
经常遇到有的linux服务器由于特殊原因,不能连接外网,但是经常需要安装一些软件,尤其是在编译一些包的时候经常由于没有安装一些依存包而报的各种各样的错误,当你找到依存的rpm包去安装的时候,又提示你有 ...
- ace admin 下拉选择Multiple-select组件
一.组件说明以及API 1.第一个组件是写bootstrap table的主人公 wenzhixin 封装的一个组件—— multiple-select.这个组件风格简单.文档全.功能强大.但是觉得它 ...