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;
    }
  • 相关阅读:
    Guava入门第四章(Objects)
    Guava入门第三章(Preconditions)
    Guava入门第二章(Splitter)
    Guava入门第一章(Joiner)
    Docker入门第六章
    Docker遇到的问题
    Docker命令图
    2016-08-26-Java比较器的使用
    2017-10-6-MyBatis配置简述
    2017-9-17-Java Exception小结
  • 原文地址:https://www.cnblogs.com/LLTYYC/p/11580338.html
Copyright © 2011-2022 走看看