Tenth Blue Bridge Cup Group B Match A provincial title

Questions A: team 

【Problem Description】 

As a basketball coach, you need to select No. 1-5 digit number one player each from the following list, the composition of the team's starting lineup. 

When the score of each player as No. 1 to No. 5 shown in the following table. Please calculate the starting lineup No. 1 to No. 5 in the sum of the maximum possible score is how much? 

490

 

#include <stdio.h>

#include<iostream>

#include<string>

#include <algorithm> // sort function header contains

using namespace std;

 

       struct t{

              int a[5];

              int num;

       }some[20];

       

    int some1[20][5]={

       97       ,90       ,0       ,0,       0,

       92       ,85       ,96       ,0,       0,

       0,       0,       0       ,0       ,93,

       0       ,0,       0,       80       ,86, 

       89,       83,       97,       0,       0, 

       82,       86,       0,       0,       0, 

       0,       0,       0,       87,       90, 

       0,       97,       96,       0,       0, 

       0,       0,       89,       0,       0, 

       95,       99       ,0,       0,       0, 

       0,       0,       96,       97,       0, 

       0,       0,       0,       93,       98, 

       94,       91,       0,       0,       0, 

       0,       83,       87,       0,       0, 

       0,       0,       98,       97,       98, 

       0,       0,       0,       93,       86, 

       98,       83,       99,       98,       81, 

       93,       87,       92,       96,       98, 

       0,       0,       0,       89,       92, 

       0,       99,       96,       95,       81

       }; //Raw data

       

    int any [5] [5]; // retrieve data

    int name [5] [5]; // name removed

    int names [20]; // iterate name

    int plays [5]; // iterate

    int num [5]; // type of occupation ah

    int i,j,k,c,amax,temp;

    int name1,name2,name3,fractionfe1,fractionfe2,fractionfe3;

    

//int some[5][20];

bool cmp(t aa,t bb){

    return aa.a[k]>bb.a[k];

}

 

void zzz(int bbb)

{

       int i,j;

    if(bbb==5){

        amax=amax>temp?amax:temp;

        return;

    }

    for(i=0;i<5;i++){

        if(num[i]==0){

               whether [i] = 1;

        for(j=0;j<5;j++){

               if(names[name[i][j]]==0){

                      break;       

                      // pruning 

               }

        }

              names[name[i][j]]=1;

              temp+=any[i][j];

           zzz (bbb + 1);

              temp-=any[i][j];

        names[name[i][j]]=0;

        whether [i] = 0;

        }

    }

}

 

int main () {

       c=0;

    for(i=0;i<20;i++){

        names[i]=0;

    }

    for(i=0;i<5;i++){

        plays[i]=0;

        whether [i] = 0;

        for(j=0;j<5;j++){

            any[i][j]=0;

            name[i][j]=0;

        }

    }

    for(i=0;i<20;i++){

           some[i].num=i;

           for(j=0;j<5;j++){

                       some[i].a[j]=some1[i][j];

              }

       }

       

    for(k=0;k<5;k++){

        sort(some,some+20,cmp);

        for(i=4;i>=0;i--){

               any[k][i]=some[i].a[k];

               name[k][i]=some[i].num;

           }

    }

    

    for(i=0;i<20;i++){

           for(j=0;j<5;j++){

        printf("%d ",some[i].a[j]);

              }

        printf("\n");

       }

       

    for(i=0;i<5;i++){

        for(j=0;j<5;j++){

        printf(" %d %d ",name[i][j],any[i][j]);

        }

        printf("\n");

    }

    

    amax=0;

    temp=0;

    

    zzz(0);

    

    printf("%d",amax);

    return 0;

}

Guess you like

Origin www.cnblogs.com/tlysMoodspace/p/11842214.html