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

性病医院网站优化服务商青岛网站建设详细内容

性病医院网站优化服务商,青岛网站建设详细内容,东莞建设银行网点查询,WordPress全局响应Problem - 1579E2 - Codeforces Array Optimization by Deque - 洛谷 | 计算机科学教育新生态 (luogu.com.cn) 树状数组解法 将 a i a_i ai​插入到队头#xff0c;贡献为#xff1a;原队列中所有比 a i a_i ai​小的数的数量将 a i a_i ai​插入到队尾#xff0c;贡献为贡献为原队列中所有比 a i a_i ai​小的数的数量将 a i a_i ai​插入到队尾贡献为原队列中所有比 a i a_i ai​大的数的数量 可以发现对于每一次插入a值影响插入的只跟已经放入的大于a或小于a的数量有关。 需要一个数据结构满足动态修改、查询。可以发现树状数组可以做这些操作不过 a i a_i ai​较大开不下数组可以离散化。 在离散化后本题转为查询 a i a_i ai​前面的数量和后面的数量大于/小于。如果前面的数量小就插前面否则插入后面将答案进行更新。 #include iostream #include vector #include string #include cstring #include set #include map #include queue #include ctime #include random #include sstream #include numeric #include stdio.h #include functional #include bitset #include algorithm using namespace std;#define Multiple_groups_of_examples #define int_to_long_long #define IOS std::cout.tie(0);std::cin.tie(0)-sync_with_stdio(false); // 开IOS需要保证只使用Cpp io流 * #define dbgnb(a) std::cout #a a \n; #define dbgtt cout !!!test!!! \n; #define rep(i,x,n) for(int i x; i n; i)#define all(x) (x).begin(),(x).end() #define pb push_back #define vf first #define vs secondtypedef long long LL; #ifdef int_to_long_long #define int long long #endif typedef pairint,int PII;const int INF 0x3f3f3f3f; const int N 2e5 21;template class T struct Fenwick { int n;vectorT a;Fenwick(const int n 0) : n(n), a(n, T()) {}void modify(int i, T x) {for (i; i n; i i -i) {a[i - 1] x;}}T get(int i) {T res T();for (; i 0; i - i -i) {res a[i - 1];}return res;}T sum(int l, int r) { // [l, r] *这里已经改过return get(r 1) - get(l);}int kth(T k) {int x 0;for (int i 1 __lg(n); i; i 1) {if (x i n k a[x i - 1]) {x i;k - a[x - 1];}}return x;} };void inpfile(); void solve() {int n; cinn;vectorint a(n);for(auto t: a) cint;// 离散化vectorint id(a);sort(all(id));id.erase(unique(all(id)), id.end());vectorint last(n);for(int i 0; i n; i) last[i] lower_bound(all(id), a[i]) - id.begin() 1;Fenwickint tr(n 21);int sum 0;for(int i 0; i n; i) {// lv表示插入队首rv表示插入队尾的逆序对值int lv tr.sum(1, last[i] - 1), rv tr.sum(last[i] 1, n 20);sum min(lv, rv);tr.modify(last[i], 1);}coutsumendl;} #ifdef int_to_long_long signed main() #else int main() #endif{#ifdef Multiple_groups_of_examplesint T; cinT;while(T--)#endifsolve();return 0; } void inpfile() {#define mytest#ifdef mytestfreopen(ANSWER.txt, w,stdout);#endif }pbds 解法 pbds库学习笔记(优先队列、平衡树、哈希表) - 知乎 (zhihu.com) 发现核心就是求排名平衡树即可。这里提供pbds的代码 #include iostream #include vector #include string #include cstring #include set #include map #include queue #include ctime #include random #include sstream #include numeric #include stdio.h #include functional #include bitset #include algorithm// pbds #include bits/extc.h using namespace __gnu_cxx; using namespace __gnu_pbds; using namespace std;#define Multiple_groups_of_examples #define int_to_long_long #define IOS std::cout.tie(0);std::cin.tie(0)-sync_with_stdio(false); // 开IOS需要保证只使用Cpp io流 * #define dbgnb(a) std::cout #a a \n; #define dbgtt cout !!!test!!! \n; #define rep(i,x,n) for(int i x; i n; i)#define all(x) (x).begin(),(x).end() #define pb push_back #define vf first #define vs secondtypedef long long LL; #ifdef int_to_long_long #define int long long #endif typedef pairint,int PII;const int INF 0x3f3f3f3f; const int N 2e5 21; // pbds typedef treePII, null_type, lessPII, rb_tree_tag, tree_order_statistics_node_update Tree; void inpfile(); void solve() {int n; cinn;Tree tr;int sum 0;for(int i 0; i n; i) {int t; cint;int lv tr.order_of_key({t, 0}), rv i - tr.order_of_key({t, n});sum min(lv, rv);tr.insert({t, i});}coutsumendl; } #ifdef int_to_long_long signed main() #else int main() #endif{#ifdef Multiple_groups_of_examplesint T; cinT;while(T--)#endifsolve();return 0; } void inpfile() {#define mytest#ifdef mytestfreopen(ANSWER.txt, w,stdout);#endif }pbds库学习笔记(优先队列、平衡树、哈希表) - 知乎 (zhihu.com)
http://www.huolong8.cn/news/349435/

相关文章:

  • 清远网站推广优化公司做网站需要多久
  • 人才网站查询档案企业网站规划与开发
  • 网络企业做网站徐州市建设局官方网站
  • win2008的iis7建网站流程房产网站系统哪个好
  • 温江 网站建设快递网站模版
  • 快递系统专注快递企业网站开发长沙网站推广排名优化
  • 河北农业建设信息网站营销网站建设的公司
  • 定州市住房保障和城乡建设局网站网站有风险提示怎么办
  • 建设一个网站需要什么技术指标中太建设集团网站
  • 深圳市建设工程质量检测中心网站编程开源网站
  • 网站建设项目验收方案彩票网站的建设
  • 2017湖北建设教育协会网站wordpress太强大
  • 怎么做电影流量网站网站关键词如何布局
  • 中国站免费推广入口wordpress 功能 删除
  • custed谁做的网站开网店怎么卖到外国
  • 门户网站服务范围简述网站建设方法
  • 做网站需要跟客户了解什么网站建设合同技术开发合同
  • 太原免费网站建站模板网站建设流程有几个阶段
  • 网站备案每年一次吗名医工作室 网站建设
  • 安徽城乡建设厅官方网站福州做网站的公司电话
  • 网站建站公司哪家价钱合理网站整体设计
  • 建设银行积分网站wordpress 时间代码
  • 如何通过域名访问网站网站开发 定制 多少 钱
  • 网站备案是什么建工教育网校官方网站
  • 网站建站系统有哪些益阳市住房和建设局 网站
  • 高校网站群建设免费建设小说网站
  • 做代金券的网站wordpress站点搬家
  • 如何做响应式布局网站网络营销策划推广公司招聘
  • 如何用天地图做网站兰州门户网站建设
  • 洛阳青峰网络公司做网站顺企网下载