当前位置:网站首页>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
边栏推荐
- R language [data management]
- 基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
- JMeter installation under win7
- 递归查询多级菜单数据
- Which securities company is better and which platform is safer for stock account opening
- matlab绘制hsv色轮图
- 2.2.3 output of documents
- 办公遇到的问题--
- Gcc9.5 offline installation
- R language learning notes
猜你喜欢

leetcode:1755. Sum of subsequences closest to the target value

2022-07-03-cka- latest feedback from fans

Experienced inductance manufacturers tell you what makes the inductance noisy. Inductance noise is a common inductance fault. If the used inductance makes noise, you don't have to worry. You just need

JMeter installation under win7

张丽俊:穿透不确定性要靠四个“不变”

How to prepare for the algorithm interview and answer the algorithm interview questions

MMAP学习

第05章_存储引擎

EN 438-7 laminated sheet products for building covering decoration - CE certification

Some common processing problems of structural equation model Amos software
随机推荐
Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes
思特奇加入openGauss开源社区,共同推动数据库产业生态发展
Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
The primary key is set after the table is created, but auto increment is not set
selenium 查找b或p标签的内容
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
Longest swing sequence [greedy practice]
MySQL InnoDB Architecture Principle
Which securities company is better and which platform is safer for stock account opening
资深电感厂家告诉你电感什么情况会有噪音电感噪音是比较常见的一种电感故障情况,如果使用的电感出现了噪音大家也不用着急,只需要准确查找分析出什么何原因,其实还是有具体的方法来解决的。作为一家拥有18年品牌
PostGIS installation geographic information extension
Li Kou ----- the maximum profit of operating Ferris wheel
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
怎么利用Tensorflow2进行猫狗分类识别
Golang (1) | from environmental preparation to quick start
面试官:并发编程实战会吗?(线程控制操作详解)
第05章_存储引擎
datagrid直接编辑保存“设计缺陷”
MMAP learning