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

网络营销专业就业公司sem和seo是什么

网络营销专业就业公司,sem和seo是什么,网站怎么做后台,去年做哪个网站能致富离散化是将大范围的数字映射到小范围的区间内,适用于稀疏的区间。 两个问题需要考虑: 1. 原数组中可能有重复元素,需要去重。 2. 如何算出离散化后的值(离散化后保序,使用二分)。 题目链接: …

离散化是将大范围的数字映射到小范围的区间内,适用于稀疏的区间。

两个问题需要考虑:

1. 原数组中可能有重复元素,需要去重。

2. 如何算出离散化后的值(离散化后保序,使用二分)。

题目链接:

https://www.acwing.com/problem/content/804/

代码:

#include <iostream>
#include <vector>
#include <algorithm>using namespace std;typedef pair<int, int> PII;const int N = 300010;int n, m;
int a[N], s[N];vector<int> alls;
vector<PII> add, query;int find(int x)
{int l = 0, r = alls.size() - 1;while (l < r){int mid = l + r >> 1;if (alls[mid] >= x) r = mid;else l = mid + 1;}return r + 1;
}int main()
{cin >> n >> m;for (int i = 0; i < n; i++){int x, c;cin >> x >> c;add.push_back({x, c});alls.push_back(x);}for (int i = 0; i < m; i++){int l, r;cin >> l >> r;query.push_back({l, r});alls.push_back(l);alls.push_back(r);}// 去重sort(alls.begin(), alls.end());alls.erase(unique(alls.begin(), alls.end()), alls.end());// 处理插入for (auto item : add){int x = find(item.first);a[x] += item.second;}// 预处理前缀和for (int i = 1; i <= alls.size(); i++) s[i] = s[i - 1] + a[i];// 处理询问for (auto item : query){int l = find(item.first), r = find(item.second);cout << s[r] - s[l - 1] << endl;}return 0;
}

其中,unique(alls.begin(), alls.end())将数组中的所有重复元素去重,返回去重后的数组的尾端点。使用Java和Python的小伙伴可以使用下列自己实现的方法替换(双指针算法):

vector<int>::iterator unique(vector<int>& a)
{int j = 0;for (int i = 0; i < a.size(); i++)if (!i || a[i] != a[i - 1])a[j++] = a[i];// a[0] ~ a[j - 1] 所有a中不重复的数return a.begin() + j;
}

http://www.tj-hxxt.cn/news/73192.html

相关文章:

  • 做软装的网站中文网站排名
  • 深圳响应式建站做seo前景怎么样
  • 江苏省城乡建筑信息网seo优化怎么做
  • 网站建设链接seo站长工具平台
  • 做营销网站企业企业软文营销发布平台
  • 做网站公司官网网站策划是做什么的
  • 免费做网站表白专业培训大全
  • 网站建设链接为企业策划一次网络营销活动
  • thinkphp 门户网站新闻播报最新
  • js博客网站开发计划书网络推广引流是做什么工作
  • 常州网站建设企业网站微信销售平台
  • 怎么做网站用dreamwer百度官方客服
  • 色彩学习网站互联网怎么赚钱
  • 敦化网站建设seo推广视频隐迅推专业
  • 荆州哪里做网站seo域名综合查询
  • 360网址大全电脑版重庆seo网络优化咨询热线
  • wordpress怎么把分类弄在左边seo在线论坛
  • 叫别人做网站需要注意什么问题百度手机版下载
  • html网站列表怎么做seo教程免费
  • 做备案的网站优化游戏卡顿的软件
  • 网站项目的流程百度免费官网入口
  • 如何创建自己的软件天津抖音seo
  • wordpress和the7主题的关系湖南seo优化排名
  • 如何用图片做网站背景无安全警告的浏览器
  • 做购物网站用服务器微信营销模式
  • 滁州新手跨境电商建站哪家好最新的军事新闻
  • 营销型网站报价seo推广排名平台有哪些
  • 服装设计网站免费西安关键词排名优化
  • 做网站如何寻找客源有实力的网站排名优化软件
  • 建设网站网页打不开保定seo建站