当前位置:网站首页>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
边栏推荐
- EN 438-7 laminated sheet products for building covering decoration - CE certification
- Incentive mechanism of Ethereum eth
- R language [data management]
- Implementing Lmax disruptor queue from scratch (IV) principle analysis of multithreaded producer multiproducersequencer
- Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
- How to prepare for the algorithm interview and answer the algorithm interview questions
- Teach yourself to train pytorch model to Caffe (I)
- Which securities company is better and which platform is safer for stock account opening
- DBeaver同时执行多条insert into报错处理
- Yolov5 training custom data set (pycharm ultra detailed version)
猜你喜欢
EBS Oracle 11g 克隆步骤(单节点)
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Sorting out the problems encountered in MySQL built by pycharm connecting virtual machines
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
Oracle检查点队列–实例崩溃恢复原理剖析
SQL knowledge leak detection
2.2.3 output of documents
Teach yourself to train pytorch model to Caffe (I)
Teach yourself to train pytorch model to Caffe (III)
MySQL InnoDB Architecture Principle
随机推荐
【日常训练】729. 我的日程安排表 I
张丽俊:穿透不确定性要靠四个“不变”
Alibaba cloud award winning experience: build a highly available system with polardb-x
123456
Interview questions for basic software testing
leetcode:1755. Sum of subsequences closest to the target value
第05章_存储引擎
Simple interest mode - lazy type
QML reported an error expected token ";", expected a qualified name ID
EasyExcel的读写操作
MMAP learning
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
kingbaseES V8R3数据安全案例之---审计记录清除案例
HDU 4391 Paint The Wall 段树(水
办公遇到的问题--
Interviewer: will concurrent programming practice meet? (detailed explanation of thread control operation)
Cold violence -- another perspective of objective function setting
What should I do to prepare for the interview algorithm position during school recruitment?
递归查询多级菜单数据
Access Zadig self-test environment outside the cluster based on ingress controller (best practice)