当前位置:网站首页>Codeforces 12D ball tree array simulation 3 sorting elements
Codeforces 12D ball tree array simulation 3 sorting elements
2022-07-05 21:43:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack
Topic links : Click to open the link
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<set>
#include<vector>
#include<map>
#include<math.h>
#include<queue>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
#define N 500005
#define ll int
ll n;
ll c[N], maxn;
inline ll lowbit(ll x){return x&(-x);}
void change(ll pos, ll val){
while(pos)c[pos]=max(c[pos],val), pos-=lowbit(pos);
}
ll maxx(ll pos){
ll ans = -1;
while(pos<=maxn)ans = max(ans,c[pos]),pos+=lowbit(pos);
return ans;
}
struct node{
ll b[3],num;
}w[N];
bool cmp0(node x, node y){return x.b[0]<y.b[0];}
bool cmp1(node x, node y){return x.b[1]>y.b[1];}
int main(){
ll i,j;
while(cin>>n) {
for(i=0;i<n;i++)scanf("%d",&w[i].b[0]);
for(i=0;i<n;i++)scanf("%d",&w[i].b[1]);
for(i=0;i<n;i++)scanf("%d",&w[i].b[2]);
sort(w, w+n, cmp0);
ll rank = 1;
w[0].num = 1;
for(i=1;i<n;i++) {
if(w[i].b[0]==w[i-1].b[0])w[i].num = rank;
else w[i].num = ++rank;
}
sort(w,w+n,cmp1);
for(i=1;i<=rank;i++)c[i]=-1;
maxn = rank;
i = 0;
ll ans = 0;
while(i<n) {
for(j = i; j < n && w[i].b[1] == w[j].b[1]; j++)
if(maxx(w[j].num+1)>w[j].b[2])
ans++;
for(j = i; j < n && w[i].b[1] == w[j].b[1]; j++)
change(w[j].num, w[j].b[2]);
i = j;
}
cout<<ans<<endl;
}
return 0;
}Copyright notice : This article is an original blog article , Blog , Without consent , Shall not be reproduced .
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/117583.html Link to the original text :https://javaforall.cn
边栏推荐
- 2.2 basic grammar of R language
- Detailed explanation of memset() function usage
- matlab绘制hsv色轮图
- selenium 查找b或p标签的内容
- EL与JSTL注意事项汇总
- 张丽俊:穿透不确定性要靠四个“不变”
- Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
- Interview questions for basic software testing
- 使用Aspect制作全局异常处理类
- Making global exception handling classes with aspect
猜你喜欢

第05章_存储引擎

Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines

matlab绘制hsv色轮图

Recursive query of multi-level menu data

华为快游戏调用登录接口失败,返回错误码 -1

Defect detection - Halcon surface scratch detection

EasyExcel的读写操作

"Grain mall" -- Summary and induction

Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer

Cold violence -- another perspective of objective function setting
随机推荐
"Grain mall" -- Summary and induction
终端安全能力验证环境搭建和渗透测试记录
Parker驱动器维修COMPAX控制器维修CPX0200H
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
秋招将临 如何准备算法面试、回答算法面试题
Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes
postgis 安装地理信息扩展
MySQL InnoDB Architecture Principle
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
面试官:并发编程实战会吗?(线程控制操作详解)
SecureCRT使用提示
854. 相似度为 K 的字符串 BFS
Cold violence -- another perspective of objective function setting
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)
Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
Establishment of terminal security capability verification environment and penetration test records
Selenium gets the verification code image in DOM
MMAP学习
oracle 控制文件的多路复用
Which securities company is better and which platform is safer for stock account opening