Codeforces Round #588 (Div. 2) D题【补题ING】

思路:先找出现次数>=2数。然后在取跑所有数,需要考虑一般情况(当一个人比另一个人的ai小且他们的与运算等于小的那个人的ai那么可以知道大的那个人必定强于ai小的那个人)。
则可以用位运算实现判断强弱。
#include<bits/stdc++.h> using namespace std;
#define int long long
#define N 100500
struct str{
int a,b;
}st[N];
map<int,int> mp;
vector<int> v;
signed main(){
int n;
cin>>n;
for(int i=;i<=n;i++) {
cin>>st[i].a;mp[st[i].a]++;
}
for(int i=;i<=n;i++) cin>>st[i].b;
int ans=;
for(int i=;i<=n;i++){ if(mp[st[i].a]>=){
ans+=st[i].b;
v.push_back(st[i].a);
}
}
for(int i=;i<=n;i++){
if(mp[st[i].a]>=)
continue;
for(int j=;j<v.size();j++){
if(v[j]>st[i].a&&(v[j]&st[i].a)==st[i].a){
v.push_back(st[i].a);
ans+=st[i].b;
break;
}
}
}
cout<<ans<<'\n';
return ;
} /* 11
11
10 010
101
*/
Codeforces Round #588 (Div. 2) D题【补题ING】的更多相关文章
- Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和
Codeforces Round #588 (Div. 2)-E. Kamil and Making a Stream-求树上同一直径上两两节点之间gcd的和 [Problem Description ...
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)
链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...
- Codeforces Round #499 (Div. 2) Problem-A-Stages(水题纠错)
CF链接 http://codeforces.com/contest/1011/problem/A Natasha is going to fly to Mars. She needs to bui ...
- Codeforces Round #796 (Div. 2)(A~E题题解)
文章目录 原题链接: A.Cirno's Perfect Bitmasks Classroom 思路 代码 B.Patchouli's Magical Talisman 思路 代码 C.Manipul ...
- Codeforces Round #243 (Div. 2) B(思维模拟题)
http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...
随机推荐
- Spring Boot系列教程十二:Spring boot集成Redis
一.创建项目 项目名称为 "springboot_redis",创建过程中勾选 "Web","Redis",第一次创建Maven需要下载依赖 ...
- VC++类型转换
一.其他数据类型转换为字符串 短整型(int) itoa(i,temp,10):///将i转换为字符串放入temp中,最后一个数便是十进制 itoa(i,temp,2):///按二进制方式转换 长整型 ...
- Centos7.3安装sonarqube
安装使用sonarqube 前置依赖 mysql 5.6 or 5.7 jdk 1.8 1.下载 https:/ ...
- Python 第一式
@Codewars Python练习 question ** Dashatize it ** Given a number, return a string with dash'-'marks bef ...
- ubuntu装openssh-client和openssh-server
1. 修改update源 进入/etc/apt/目录,首先用cp命令将sources.list备份成sources.list.bk,然后复制http://www.cnblogs.com/eastson ...
- JQuery的事件处理、Jason
事件的处理: <body> <div id="aa" style="width:100px; height:100px; background-colo ...
- CSS基础 布局
1.布局的基本位置 top 距离上边的距离right 距离右边的距离bottom 距离下边的距离left 距离左边的距离 去掉布局时 html 的3mm ...
- Android 启动流程分析
原文:https://www.jianshu.com/p/a5532ecc8377 作者曾经在高通的Android性能组工作,主要工作是优化Android Application的启动时间. APP基 ...
- Linux学习笔记(十二)VIM编辑器
一.概述 VI Visual interface 可视化接口,类似于Windows中的记事本 VI->VIM 操作模式: (1)Command mode 命令模式 (2)Insert mode ...
- LeetCode--字符串
1.给定字符串s,分区s使得分区的每个子字符串都是回文. 返回s的所有可能的回文分区.例如,给定s =“aab”,返回 [ ["aa","b"], [" ...