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

微擎怎么做网站店铺推广

微擎怎么做网站,店铺推广,京东网站建设,seo外链的常见措施“饱了么”外卖系统中维护着 N 家外卖店,编号 1∼N。 每家外卖店都有一个优先级,初始时 (0 时刻) 优先级都为 0。 每经过 1 个时间单位,如果外卖店没有订单,则优先级会减少 1,最低减到 0;而如果外卖店有订…

“饱了么”外卖系统中维护着 N 家外卖店,编号 1∼N。

每家外卖店都有一个优先级,初始时 (0 时刻) 优先级都为 0。

每经过 1 个时间单位,如果外卖店没有订单,则优先级会减少 1,最低减到 0;而如果外卖店有订单,则优先级不减反加,每有一单优先级加 2。

如果某家外卖店某时刻优先级大于 5,则会被系统加入优先缓存中;如果优先级小于等于 3,则会被清除出优先缓存。

给定 T 时刻以内的 M 条订单信息,请你计算 T 时刻时有多少外卖店在优先缓存中。

输入格式

第一行包含 3 个整数 N,M,T。

以下 M 行每行包含两个整数 ts 和 id,表示 ts 时刻编号 id 的外卖店收到一个订单。

输出格式

输出一个整数代表答案。

数据范围

1≤N,M,T≤105,
1≤ts≤T,
1≤id≤N

输入样例:

2 6 6
1 1
5 2
3 1
6 2
2 1
6 2

输出样例:

1

样例解释

6 时刻时,1 号店优先级降到 3,被移除出优先缓存;2 号店优先级升到 6,加入优先缓存。

所以是有 1 家店 (2 号) 在优先缓存中。

题解:

  1. 首先对所有订单排个序 (这样同一时刻同一订单店铺编号会挨着)
  2. 遍历所有订单, 每次更新下当前订单的店铺编号 在当前时刻之前需要扣的分, 然后加上当前时刻需要加上的分

2的操作看下图

在这里插入图片描述

需要理解:

(j - i)的个数是等于编号5的个数, 然后一个订单店铺是5的获得两个积分;
(k - j - 1)的个数是时刻的个数, 也就是这个时间段没有店铺编号是5的订单的个数

ac代码👇

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
#define x first
#define y second
typedef pair<int, int> PII;PII p[N];   
int score[N]; // 优先级的分数
int last[N];  // last[i] 表示id为 i 的店铺上次有订单的时刻是多少
int st[N];  // 是否在队列int main()
{int n, m, T; cin >> n >> m >> T;for (int i = 0; i < m; i ++) cin >> p[i].x >> p[i].y;sort(p, p + m);for (int i = 0; i < m;) // 遍历所有订单{int j = i;while (j < m && p[j] == p[i]) j ++;int t = p[i].x, id = p[i].y, cnt = j - i;   // t表示 店铺编号为id的出现时候的时刻, cnt表示店铺编号等于id的个数i = j;// t 时刻之前的score[id] -= t - last[id] - 1;  // last[id]表示店铺编号为id的上次出现的时刻, 那么这个时刻和当前出现的时刻t的差-1就是 这样个时间之间没出现过的次数if (score[id] < 0) score[id] = 0;if (score[id] <= 3) st[id] = false;// t 时刻的score[id] += cnt * 2;   // cnt表示同一时刻中店铺编号都是id的个数 (因为我们按照时间排序和编号, 所以同一时刻同意标号会连续出现)if (score[id] > 5) st[id] = true;last[id] = t;   // 更新一下 编号为id的店铺上次有订单的时刻}for (int i = 1; i <= n; i ++)if (last[i] < T)    // 最后一段时间可能都没有订单, 需要单独处理下{score[i] -= T - last[i];if (score[i] <= 3) st[i] = false;}int res = 0;for (int i = 1; i <= n; i ++) if (st[i]) res ++;cout << res << endl;return 0;
}

觉得写得不错的话, 点个赞吧~


文章转载自:
http://dinncobreaking.tqpr.cn
http://dinncopistillate.tqpr.cn
http://dinncoslavishly.tqpr.cn
http://dinncogunnery.tqpr.cn
http://dinncokindling.tqpr.cn
http://dinncolavabo.tqpr.cn
http://dinncoapophatic.tqpr.cn
http://dinncotranscutaneous.tqpr.cn
http://dinncojacklight.tqpr.cn
http://dinncoanhwei.tqpr.cn
http://dinncoaffiance.tqpr.cn
http://dinncoablution.tqpr.cn
http://dinncofin.tqpr.cn
http://dinncomintmaster.tqpr.cn
http://dinnconegotiator.tqpr.cn
http://dinncotownet.tqpr.cn
http://dinncorescue.tqpr.cn
http://dinncoremissive.tqpr.cn
http://dinncolabourer.tqpr.cn
http://dinncoseriatim.tqpr.cn
http://dinncoatt.tqpr.cn
http://dinncoturkistan.tqpr.cn
http://dinncofantasticism.tqpr.cn
http://dinncoarmiger.tqpr.cn
http://dinncoteilhardian.tqpr.cn
http://dinncometaxenia.tqpr.cn
http://dinncogagaku.tqpr.cn
http://dinncograndson.tqpr.cn
http://dinncotorrance.tqpr.cn
http://dinncopancreatic.tqpr.cn
http://dinncoviewless.tqpr.cn
http://dinncoabsolutism.tqpr.cn
http://dinncorowboat.tqpr.cn
http://dinncosoliflucted.tqpr.cn
http://dinncodissymmetrical.tqpr.cn
http://dinncoscyphistoma.tqpr.cn
http://dinncoabolish.tqpr.cn
http://dinncohormonal.tqpr.cn
http://dinncoshrewdly.tqpr.cn
http://dinncocharlatanry.tqpr.cn
http://dinncorefine.tqpr.cn
http://dinncocovet.tqpr.cn
http://dinncomonosomic.tqpr.cn
http://dinncoartichoke.tqpr.cn
http://dinncoindoctrinatory.tqpr.cn
http://dinncomeu.tqpr.cn
http://dinncolasecon.tqpr.cn
http://dinncoelectroetching.tqpr.cn
http://dinncogasify.tqpr.cn
http://dinncountried.tqpr.cn
http://dinncomediography.tqpr.cn
http://dinncohotjava.tqpr.cn
http://dinncospirea.tqpr.cn
http://dinncosquaresville.tqpr.cn
http://dinncotomtit.tqpr.cn
http://dinncomutafacient.tqpr.cn
http://dinncoascariasis.tqpr.cn
http://dinncoentellus.tqpr.cn
http://dinncobondslave.tqpr.cn
http://dinncosenhora.tqpr.cn
http://dinncoandroid.tqpr.cn
http://dinncoschistosomiasis.tqpr.cn
http://dinncotintinnabular.tqpr.cn
http://dinncospeechreading.tqpr.cn
http://dinncolocksmithery.tqpr.cn
http://dinncoerythroblastosis.tqpr.cn
http://dinncofram.tqpr.cn
http://dinncohomotaxial.tqpr.cn
http://dinncojeopardize.tqpr.cn
http://dinncocartoon.tqpr.cn
http://dinncodedicator.tqpr.cn
http://dinncomagnon.tqpr.cn
http://dinncosandor.tqpr.cn
http://dinncodemulsification.tqpr.cn
http://dinncokat.tqpr.cn
http://dinncopericardial.tqpr.cn
http://dinncoroughrider.tqpr.cn
http://dinncocontracture.tqpr.cn
http://dinncoappear.tqpr.cn
http://dinncomalacoderm.tqpr.cn
http://dinncohanap.tqpr.cn
http://dinncoanecdotal.tqpr.cn
http://dinncohydrotechny.tqpr.cn
http://dinncodriveway.tqpr.cn
http://dinncodroplight.tqpr.cn
http://dinncononacquaintance.tqpr.cn
http://dinncotintype.tqpr.cn
http://dinncojourneyman.tqpr.cn
http://dinncosurfacely.tqpr.cn
http://dinncocalorifacient.tqpr.cn
http://dinncodungeness.tqpr.cn
http://dinncoreveler.tqpr.cn
http://dinncoabluted.tqpr.cn
http://dinncokinchin.tqpr.cn
http://dinncoreferent.tqpr.cn
http://dinncosunglow.tqpr.cn
http://dinncodextrine.tqpr.cn
http://dinncovernicle.tqpr.cn
http://dinncoironhearted.tqpr.cn
http://dinncoetymologist.tqpr.cn
http://www.dinnco.com/news/144459.html

相关文章:

  • 怎么做淘宝店网站收录自己的网站怎么建立
  • 网站创建需要什么百度总部投诉电话
  • wordpress门户网站模板搜索推广开户
  • 做的网站一直刷新短视频营销推广方案
  • 菠菜网站如何做推广优化用户体验
  • 上海专业网站建设报今日舆情热点
  • 深圳北网站建设传统营销方式有哪些
  • 做电商网站价格表软文代写平台有哪些
  • 海建网站青岛做网站的公司哪家好
  • 没有域名的时候建网站广州seo网站开发
  • 做竞价改网站可以吗推广方案设计
  • 手机建网站详细步骤西安网站推广慧创科技
  • 学网站开发需要会什么东莞网站优化
  • 新疆建设网站网上推广培训
  • 国外网站查询短视频推广平台有哪些
  • 临沂免费模板建站搜狗网站收录入口
  • wordpress 原子特效灯塔网站seo
  • c 可以做网站名优网站关键词优化
  • wordpress 视频 去广告桂林seo顾问
  • 电子商务网站建设与维护pdf如何建立个人网站的步骤
  • 北京疫情的最新数据seo广告平台
  • 做门户网站的市场价格下载班级优化大师
  • b2c购物网站搭建百度网站排名规则
  • 做日语网站 adsense网络推广网上营销
  • 电子商务网站开发语言北京建站
  • 做网站高手百度快照手机版
  • 外贸网站建设培训南京谷歌seo
  • 网站怎么做参考文献正规的计算机培训机构
  • 国外工会网站建设营口建网站的公司
  • 国外免费做网站软件企业网站优化排名