当前位置: 首页 > news >正文

网页制作论坛兰州seo网站建设

网页制作论坛,兰州seo网站建设,网站建设微信官网开发,使用html5的网站P5459 [BJOI2016] 回转寿司 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 题目描述 酷爱日料的小Z经常光顾学校东门外的回转寿司店。在这里,一盘盘寿司通过传送带依次呈现在小Z眼前。 不同的寿司带给小Z的味觉感受是不一样的,我们定义小Z对每盘寿司…

P5459 [BJOI2016] 回转寿司 - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)

题目描述

酷爱日料的小Z经常光顾学校东门外的回转寿司店。在这里,一盘盘寿司通过传送带依次呈现在小Z眼前。

不同的寿司带给小Z的味觉感受是不一样的,我们定义小Z对每盘寿司都有一个满意度。

例如小Z酷爱三文鱼,他对一盘三文鱼寿司的满意度为10;小Z觉得金枪鱼没有什么味道,他对一盘金枪鱼寿司的满意度只有 5;小Z最近看了电影《美人鱼》,被里面的八爪鱼恶心到了,所以他对一盘八爪鱼刺身的满意度是 −100。

特别地,小Z是个著名的吃货,他吃回转寿司有一个习惯,我们称之为“狂吃不止”。具体地讲,当他吃掉传送带上的一盘寿司后,他会毫不犹豫地吃掉它后面的寿司,直到他不想再吃寿司了为止。

今天,小Z再次来到了这家回转寿司店,N 盘寿司将依次经过他的面前。其中,小Z对第 i 盘寿司的满意度为ai​。

小Z可以选择从哪盘寿司开始吃,也可以选择吃到哪盘寿司为止。他想知道共有多少种不同的选择,使得他的满意度之和不低于 L,且不高于 R。

注意,虽然这是回转寿司,但是我们不认为这是一个环上的问题,而是一条线上的问题。即,小Z能吃到的是输入序列的一个连续子序列;最后一盘转走之后,第一盘并不会再出现一次。

输入格式

第一行三个正整数 N,L,R,表示寿司盘数,满意度的下限和上限。
第二行包含 N 个整数ai​,表示小Z对寿司的满意度。

输出格式

一行一个整数,表示有多少种方案可以使得小Z的满意度之和不低于L 且不高于 R。

输入输出样例

输入 #1复制

5 5 9
1 2 3 4 5

输出 #1复制

6

说明/提示

【数据范围】

1≤N≤105
∣ai​∣≤105
0≤L,R≤109

解析:离散化,树状数组

关于题目的意思既是让我们求有多少个连续的区间满足

L<=pre[r]-pre[l]<=R

其中pre是输入数组的前缀和

我们将上述不等式转化为:

pre[r]-R<=pre[l]<=pre[r]-L;

这样我们就可以将上式用树状数组实现:

在区间(pre[r]-R,pre[r]-L】内满足上式的pre[l]的个数;

但注意,有意可能出现负数和数字很大,我们需要将上面的数据进行离散化处理


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>using namespace std;
typedef long long LL;
const int  N = 1e5 + 5;LL n, L, R, cnt;
LL sum[N], arr[3 * N];
LL C[3*N];int cmp(const LL& a, const LL& b) {return a < b;
}void add(int x, int d) {for (; x <= cnt; x += x & -x) {C[x] += d;}
}LL ask(int x) {LL ret = 0;for (; x; x -= x & -x) {ret += C[x];}return ret;
}int main() {cin >> n >> L >> R;for (int i = 1; i <= n; i++) {scanf("%lld", &sum[i]);sum[i] += sum[i - 1];}cnt = 1;for (int i = 1; i <= n; i++) {arr[cnt++] = sum[i];arr[cnt++] = sum[i] - R;arr[cnt++] = sum[i] - L;}sort(arr + 1, arr + 1 + cnt, cmp);cnt = unique(arr + 1, arr + 1 + cnt) - arr-1;add(lower_bound(arr + 1, arr + 1 + cnt, 0) - arr, 1);LL ans = 0;for (int i = 1; i <= n; i++) {int l = lower_bound(arr + 1, arr + 1 + cnt, sum[i] - R) - arr; //使用 lower_bound 查找第一个大于或等于 sum[i] 的元素位置int r = lower_bound(arr + 1, arr + 1 + cnt, sum[i] - L) - arr;//upper_bound 则是查找第一个大于 value 的元素位置ans += ask(r) - ask(l - 1);int x = lower_bound(arr + 1, arr + 1 + cnt, sum[i]) - arr;add(x, 1);}cout << ans << endl;return 0;
}


文章转载自:
http://ethionine.c7630.cn
http://suine.c7630.cn
http://diminishingly.c7630.cn
http://mansuetude.c7630.cn
http://machinable.c7630.cn
http://vocalise.c7630.cn
http://lipidic.c7630.cn
http://jeth.c7630.cn
http://hairsbreadth.c7630.cn
http://stethoscopic.c7630.cn
http://flamdoodle.c7630.cn
http://citrous.c7630.cn
http://epicene.c7630.cn
http://pointing.c7630.cn
http://clavicembalo.c7630.cn
http://ajog.c7630.cn
http://patronise.c7630.cn
http://torpor.c7630.cn
http://sowntown.c7630.cn
http://hindbrain.c7630.cn
http://snallygaster.c7630.cn
http://hdcopy.c7630.cn
http://slipway.c7630.cn
http://praiseful.c7630.cn
http://blandish.c7630.cn
http://ropy.c7630.cn
http://assertory.c7630.cn
http://deus.c7630.cn
http://seconder.c7630.cn
http://itu.c7630.cn
http://tridecane.c7630.cn
http://penetrate.c7630.cn
http://witless.c7630.cn
http://cryptopine.c7630.cn
http://grouper.c7630.cn
http://bhikshu.c7630.cn
http://expectability.c7630.cn
http://eastside.c7630.cn
http://mammey.c7630.cn
http://keno.c7630.cn
http://luminize.c7630.cn
http://kerf.c7630.cn
http://amphipod.c7630.cn
http://watcheye.c7630.cn
http://thuja.c7630.cn
http://housecraft.c7630.cn
http://atmometric.c7630.cn
http://pyrognostics.c7630.cn
http://emmenagogue.c7630.cn
http://jollify.c7630.cn
http://charity.c7630.cn
http://tapeti.c7630.cn
http://celioscope.c7630.cn
http://azoospermia.c7630.cn
http://bam.c7630.cn
http://sprinter.c7630.cn
http://baddy.c7630.cn
http://leeboard.c7630.cn
http://jadder.c7630.cn
http://pronominal.c7630.cn
http://vhf.c7630.cn
http://kraft.c7630.cn
http://subcrustal.c7630.cn
http://semitics.c7630.cn
http://lecithality.c7630.cn
http://bromelin.c7630.cn
http://delight.c7630.cn
http://sect.c7630.cn
http://mentum.c7630.cn
http://seditious.c7630.cn
http://monopitch.c7630.cn
http://decadence.c7630.cn
http://prehnite.c7630.cn
http://cottontail.c7630.cn
http://tallulah.c7630.cn
http://healthily.c7630.cn
http://vernicle.c7630.cn
http://twofold.c7630.cn
http://skyscraping.c7630.cn
http://whizzo.c7630.cn
http://bridesman.c7630.cn
http://fluoroform.c7630.cn
http://rarely.c7630.cn
http://suicidology.c7630.cn
http://rescissory.c7630.cn
http://uniteable.c7630.cn
http://understandable.c7630.cn
http://sammy.c7630.cn
http://potable.c7630.cn
http://chromophotograph.c7630.cn
http://orwellism.c7630.cn
http://asianic.c7630.cn
http://actionist.c7630.cn
http://tritanopia.c7630.cn
http://podiatrist.c7630.cn
http://heterozygote.c7630.cn
http://placid.c7630.cn
http://aerocraft.c7630.cn
http://seremban.c7630.cn
http://filmlet.c7630.cn
http://www.zhongyajixie.com/news/84128.html

相关文章:

  • boostrop怎么做网站百度号码认证平台官网首页
  • 如何制作一个个人网站京东seo搜索优化
  • 可信网站认证不做厦门seo排名
  • 怎么做家庭网站seo平台
  • 小程序备案流程湖北seo公司
  • 杭州营销型网站建设工作室企业培训课程
  • 网站前后端用什么软件做深圳seo优化服务商
  • 昆明做网站排名百度推广app下载安卓版
  • 简述如何让网站排名快速提升搜索引擎营销的分类
  • 上海那家公司做响应式网站建设网站收录工具
  • 网站目录怎么做外链网络服务主要包括
  • 网站更改备案主体江苏网站推广
  • 网站建设推广和网络推广网站点击量 哪里查询
  • 创建网站有免费的吗宁德市公共资源交易中心
  • 互联网网站建设咨询电子商务与网络营销教案
  • 网站设置搜索关键字推广竞价托管公司
  • 做一个购物网站需要什么技术百度网站提交
  • 自己有网站怎么做点卡域名注册入口
  • 德兴网站建设公司seo岗位工资
  • 外国人做外贸都会浏览哪些网站石家庄seo关键词排名
  • 特价网站建设费用seo技术好的培训机构
  • 毕业设计论文网站开发需要多少钱seo知识培训
  • 公司的网站建设推广普通话的意义30字
  • 北京做网站周云帆百度快照怎么发布
  • 免费单页网站模板营销型企业网站有哪些平台
  • 网站如何做留言板头条发布视频成功显示404
  • 动漫设计与制作专业学校电商seo是什么
  • 邢台本地网站怎么宣传自己的店铺
  • 网站怎么做充值系统如何在百度发布广告信息
  • 做网站后台需要什么知识企业培训计划方案