当前位置:网站首页>Codeforces 12D Ball 树形阵列模拟3排序元素
Codeforces 12D Ball 树形阵列模拟3排序元素
2022-07-05 21:41:00 【全栈程序员站长】
大家好,又见面了,我是全栈君
主题链接:点击打开链接
#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;
}版权声明:本文博客原创文章,博客,未经同意,不得转载。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/117583.html原文链接:https://javaforall.cn
边栏推荐
- 让开发效率飞速提升的跨端方案
- 股票开户选择哪家证券公司比较好哪家平台更安全
- Test of incombustibility of cement adhesives BS 476-4
- crm创建基于fetch自己的自定义报告
- 从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
- Opérations de lecture et d'écriture pour easyexcel
- Selenium's method of getting attribute values in DOM
- selenium 查找b或p标签的内容
- 办公遇到的问题--
- Chapter 05_ Storage engine
猜你喜欢

Teach yourself to train pytorch model to Caffe (III)

Access Zadig self-test environment outside the cluster based on ingress controller (best practice)

Cross end solution to improve development efficiency rapidly

JMeter installation under win7

Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture

Some common processing problems of structural equation model Amos software

PIP install beatifulsoup4 installation failed

Defect detection - Halcon surface scratch detection

怎么利用Tensorflow2进行猫狗分类识别

How can Huawei online match improve the success rate of player matching
随机推荐
Introduction of ArcGIS grid resampling method
Five layer network protocol
Feng Tang's "spring breeze is not as good as you" digital collection, logged into xirang on July 8!
xlrd常见操作
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
Parker driver maintenance COMPAX controller maintenance cpx0200h
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
2022-07-03-CKA-粉丝反馈最新情况
Alibaba cloud award winning experience: build a highly available system with polardb-x
Detailed explanation of memset() function usage
How to prepare for the algorithm interview and answer the algorithm interview questions
selenium 查找b或p标签的内容
Aitm2-0002 12s or 60s vertical combustion test
Get JS of the previous day (timestamp conversion)
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
ESP32
[daily training -- Tencent select 50] 89 Gray code (only after seeing the solution of the problem)
@Validated基础参数校验、分组参数验证和嵌套参数验证
EasyExcel的读写操作
Four components of logger