zoukankan      html  css  js  c++  java
  • Codeforces 1229A. Marcin and Training Camp

    传送门

    垃圾翻译毁一生怎么办

    题目看错直接 $GG$

    首先所有 $a_i$ 重复出现的人全都可以加入

    考虑剩下的人发现 $a$ 必须是初始那些人的子集才能加入(证明显然),设当前考虑的人为 $x$

    则集合存在 $y$ ,使得 $a_y>a_x$ 并且 $a_y ext{&} a_x=a_x$

    证明显然...真的很显然啊

    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #include<map>
    #include<vector>
    using namespace std;
    typedef long long ll;
    inline ll read()
    {
        ll x=0,f=1; char ch=getchar();
        while(ch<'0'||ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
        while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+(ch^48); ch=getchar(); }
        return x*f;
    }
    const int N=7007;
    const ll INF=1e18;
    ll n,a[N],b[N];
    ll Ans;
    vector <int> V;
    map <ll,int> cnt;
    bool vis[N];
    int main()
    {
        n=read(); if(n==1) { printf("0
    "); return 0; }
        for(int i=1;i<=n;i++) a[i]=read(),cnt[a[i]]++;
        for(int i=1;i<=n;i++) b[i]=read();
        for(int i=1;i<=n;i++) if(cnt[a[i]]>1) V.push_back(i),vis[i]=1;
        for(int i=1;i<=n;i++)
        {
            if(vis[i]) continue;
            for(auto A: V) if(a[A]>a[i]&&((a[A]&a[i])==a[i])) { V.push_back(i),vis[i]=1; break; }
        }
        for(auto A: V) Ans+=b[A];
        printf("%lld
    ",Ans);
        return 0;
    }
  • 相关阅读:
    【[Offer收割]编程练习赛12 B】一面砖墙
    【[Offer收割]编程练习赛12 A】歌德巴赫猜想
    【codeforces 779E】Bitwise Formula
    Java Web整合开发(85)
    数字
    T2602 最短路径问题 codevs
    P3378 堆【模板】 洛谷
    T1013 求先序排列 codevs
    P1717 钓鱼 洛谷
    P2085 最小函数值 洛谷
  • 原文地址:https://www.cnblogs.com/LLTYYC/p/11580338.html
Copyright © 2011-2022 走看看