试题 A: 组队

【问题描述】 作为篮球队教练,你需要从以下名单中选出 1 号位至 5 号位各一名球员, 组成球队的首发阵容。 每位球员担任 1 号位至 5 号位时的评分如下表所示。请你计算首发阵容 1 号位至 5 号位的评分之和最大可能是多少?

 

  1. import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStreamWriter;
    import java.util.Scanner;
    
    public class Main {
    
    	static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    	static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    
    	static Scanner input = new Scanner(System.in);
    
    	public static void main(String[] args) throws IOException {
    
    		int[][] aa = new int[20][5];
    		for (int i = 0; i < 20; i++) {
    			input.nextInt();
    			for (int j = 0; j < 5; j++) {
    				aa[i][j] = input.nextInt();
    			}
    		}
    
    		int maxAthleticGrade = 0;
    		for (int a = 0; a < 20; a++) {
    			for (int b = 0; b < 20; b++) {
    				for (int c = 0; c < 20; c++) {
    					for (int d = 0; d < 20; d++) {
    						for (int e = 0; e < 20; e++) {
    							if (a != b && a != c && a != d && a != e && b != c && b != d && b != e && c != d && c != e
    									&& d != e) {
    								int temp = aa[a][0] + aa[b][1] + aa[c][2] + aa[d][3] + aa[e][4];
    								maxAthleticGrade = maxAthleticGrade > temp ? maxAthleticGrade : temp;
    							}
    						}
    					}
    				}
    			}
    		}
    
    		System.out.println(maxAthleticGrade);
    
    	}
    
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值