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的更多相关文章
随机推荐
- ssh中使用spring的集成quartz 编写定时任务
之前没有使用框架开发时对于开发定时任务都是 使用java的原声timer类,重写线程的run方法跑要执行的任务.刚刚换的新公司,项目使用ssh2,目前该项目中的定时任务的使用spirng集成的quar ...
- 使用 Google 高级搜索的一些技巧
一,GOOGLE简介 Google(www.google.com)是一个搜索引擎,由两个斯坦福大学博士生Larry Page与Sergey Brin于1998年9月发明,Google Inc. 于 ...
- Pycharm 安装scrapy
因为scrapy需要依赖第三方的包,所以直接使用Pycharm安装Scrapy包无法安装成功.网上已经有很多使用cmd安装scrapy的优秀教程,此处不再介绍. 基于下图所示的结构之下向上即可完成sc ...
- 使用node.js 文档里的方法写一个web服务器
刚刚看了node.js文档里的一个小例子,就是用 node.js 写一个web服务器的小例子 上代码 (*^▽^*) //helloworld.js// 使用node.js写一个服务器 const h ...
- Ionic学习笔记1_基本布局
<body> <!-- 头部 --> bar里嵌入子元素:title,button,button-bar和 inpu ...
- php类库PHP QR Code 二维码
php类库PHP QR Code 二维码 php类库PHP QR Code 二维码 php类库PHP QR CodePHP QR Code is open source (LGPL) library ...
- nginx反向代理批量实现https协议访问
我们进入大多数HTTPS网站ie浏览器都会给出相关提醒了,但我配置了一台HTTPS代理机器发现css与js都加载不了,这个有朋友说是https页面,如果加载http协议的内容,会被认为页面不安全,所以 ...
- mongodb更新器
Name Description $inc Increments the value of the field by the specified amount. $mul Multiplies the ...
- UVA - 11584 划分字符串的回文串子串; 简单dp
/** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...
- ThinkPHP -- 问题
@.nginx下,找不到页面,如果然nginx支持pathinfo模式 原文:http://www.leixuesong.cn/1418 把文章的配置拷贝了下.