CF1230D Marcin and Training Camp

题目

Marcin and Training Camp

题目大意:
每个人有一个懂得算法值 a i a_i ai,能力值 b i b_i bi,当一个人比另一个人优秀当且仅当这个人懂得算法值得二进制数中某一位为 1 1 1的值在另一个人对应的位上不为 1 1 1。我们要找到一群人( 2 ≤ n 2 \leq n 2n),这一群人要满足,每一个都不必其他所有的人都优秀,求合法的人群的能力值的最大值。

题解

  • 显然如果有能力值重复的人,那么我们便可以找到在二进制下能力值的子集。 所有能力值在子集范围内的便可直接累加答案。

c o d e code code

#include <bits/stdc++.h> 
using namespace std; 
const int maxn = 7100; 
typedef long long LL; 

int n; 
struct node {
	LL x, y; 
} a[maxn]; 
map<LL, int> mp; 

int main() {
	scanf("%d", &n); 
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i].x); 
		mp[a[i].x]++; 
	}
	for (int i = 1; i <= n; ++i) scanf("%lld", &a[i].y); 
	set<int> st; 
	for (map<LL, int>::iterator it = mp.begin(); it != mp.end(); ++it) {
		int y = it->second; 
		LL x = it->first; 
		if (y > 1) {
			for (int i = 1; i <= n; ++i) {
				if ((a[i].x | x) == x) {
					st.insert(i); 
				}
			}
		}
	}
	LL ans = 0; 
	for (set<int>::iterator it = st.begin(); it != st.end(); ++it) {
		ans += a[*it].y; 
	}
	printf("%lld\n", ans); 
	return 0; 
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值