• API
• FAQ
• Tools
• Archive
SHARE
TWEET

# D. Marcin and Training Camp

sonprao Sep 23rd, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <bits/stdc++.h>
2. #define FOR(i,a,b) for(i=a;i<=b;i++)
3. #define FOD(i,a,b) for(i=a;i>=b;i--)
4. using namespace std;
5. long long i,n,d[1005],alg[1005][62],x,k,j,s,q,MAX;
6. bool kt;
7. int main(){
8.     pair<long long,long long> a[1005];
9.     cin>>n;
10.     FOR(i,1,n) cin>>a[i].first;
11.     FOR(i,1,n) cin>>a[i].second;
12.     sort(a+1,a+1+n);
13.     k=0;
14.     FOR(i,1,n-1)
15.     {
16.         if (a[i].first==a[i+1].first) d[++k]=i;
17.     }
18.     FOR(i,1,n)
19.     {
20.         x=a[i].first;
21.         FOR(j,1,60) {alg[i][j]=x%2; x/=2;}
22.     }
23.    // FOR(i,1,n)
24.    // {FOR(j,1,4)
25.    // cout<<alg[i][j]<<" ";
26.    // cout<<endl;}
27.     FOR(i,1,k)
28.     {
29.       //  cout<<i<<" "<<a[d[i]].first<<endl;
30.         s=0;
31.         FOR(j,1,n)
32.         {
33.             kt=true;
34.             FOR(q,1,60) if (alg[d[i]][q]<alg[j][q]) kt=false;
35.             if (kt==true) s+=a[j].second;
36.         }
37.         if (s>MAX) MAX=s;
38.     }
39.     cout<<MAX;
40.     return 0;
41. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Not a member of Pastebin yet?