脚本宝典收集整理的这篇文章主要介绍了[Usaco2016 Dec]Counting Haybales,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
#include<algorIThm> #include<iostream> #include<cstring> #include<cstdio> #define maxn 100010 using namespace std; inline int read(){ register int x(0),f(1); register char c(getchar()); while(c<'0'||'9'<c){ if(c=='-') f=-1; c=getchar(); } while('0'<=c&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar(); return x*f; } int a[maxn]; int n,m; int main(){ n=read(),m=read(); for(register int i=1;i<=n;i++) a[i]=read(); sort(a+1,a+1+n); for(register int i=1;i<=m;i++){ int x=read(),y=read(); if(x>y) swap(x,y); int l=lower_bound(a+1,a+1+n,x)-a; int r=upPEr_bound(a+1,y)-a; PRintf("%d\n",r-l); } return 0; }
以上是脚本宝典为你收集整理的[Usaco2016 Dec]Counting Haybales全部内容,希望文章能够帮你解决[Usaco2016 Dec]Counting Haybales所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。