飞步无人驾驶2018届校园招聘在线笔试A轮 register

Ended

Participants:152

Verdict:Accepted
Score:100 / 100
Submitted:2018-10-06 20:16:41

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <bits/stdc++.h>
using namespace std;
int dp[11];
int main()
{
    int n;
    while(cin>>n)
    {
        int x;
        string s;
        memset(dp,1,sizeof(dp));
        for(int i=0;i<n;i++)
        {
            cin>>x>>s;
            int r=0;
            for(int j=0;s[j];j++)
            {
                if(s[j]=='A') r=r|1;
                if(s[j]=='B') r=r|2;
                if(s[j]=='C') r=r|4;
            }
            dp[r]=min(dp[r],x);
        }
        for(int i=1;i<=7;i++)
        {
            for(int j=1;j<=i;j++)
            {
                dp[i|j]=min(dp[i|j],dp[i]+dp[j]);
            }
        }
       if(dp[7]!=dp[9]) cout<<dp[7]<<endl;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX