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