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 ...
随机推荐
- 对快速排序的理解以及相关c++代码
快速排序:在一组数据中,可以将左边的数字当作枢轴(右边也可以),接下来要做的就是,先从右边找到比枢轴小的数, 再从左边找到比枢轴大的数,接着将这两个数进行交换,重复上述步骤找出所有符合条件的数进行交换 ...
- Python 第一式
@Codewars Python练习 question ** Dashatize it ** Given a number, return a string with dash'-'marks bef ...
- 二、点亮LED
接着上一章,本章来实现控制LED的亮灭操作: 一.驱动框架 #include <linux/fs.h> #include <linux/init.h> /* 定义文件内私有结构 ...
- 【百度之星2019】Strassen
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6719 在本题中,我们只有两种方法计算两个的矩阵的乘积,第一种为定义法,需要次乘法和次加法.第二种为 ...
- 【搜索+set去重】Balance Scale
Balance Scale 题目描述 You, an experimental chemist, have a balance scale and a kit of weights for measu ...
- ASP.NET Core分布式项目-3.oauth2与open id connect 对比
oauth2 open id connect
- Kconfig语法简介
背景: 上篇文章<添加自己的驱动程序到Linux内核树中>简单介绍了在Linux内核配置中添加自己的驱动选项.但是仅靠如此简单的配置有时候不能满足我们的要求. Target :hi3531 ...
- tcpdump使用的心得
这个linux的抓包工具确实用的不多,这段时间由于处理现场的问题所以就需要这个工具,主要是要知道网卡的信息. 命令就是 tcpdump -i 网卡名
- (三)Lucene之删除更新文档以及luke的基本使用
一.demo 本例中采用单元测试,故在pom.xml中引入junit jar包 1.1 前提: public class IndexTest { /** *数据准备 */ private String ...
- Swagger 实践 <一>
参考 :https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/getting-started-with-nswag?view=aspnetcor ...