组队(蓝桥杯19A)

cpp 复制代码
#include<iostream>
#define menbn 20
#define ray 5
using namespace std;
int team[menbn][ray + 1];
bool vis[20];
int max_sum = 0;
int max(int a,int b) {
	return a > b ? a : b;
}
void dfs(int u,int sum) {
	if (u>5) {
		max_sum = max(max_sum,sum);
		return;
	}
	for (int i = 0; i < 20;i++) {
		if (!vis[i]) {
			vis[i] = true;
			dfs(u+1,sum+team[i][u]);
			vis[i] = false;
		}
	}
}
int main() {
	for (int i = 0; i < 20;i++) {
		for (int j = 0; j < 6;j++) {
			cin >> team[i][j];
		}
	}
	dfs(1,0);
	cout << max_sum;
	return 0;
}
相关推荐
山峰哥12 小时前
从全表扫描到覆盖索引:我是怎么干掉慢查询的
数据库·sql·oracle·性能优化·编辑器·深度优先
hai31524754321 小时前
一种通过空间几何转换进行软件编程计算的方式与现有计算的对比
人工智能·深度学习·数学建模·硬件架构·几何学·图论·拓扑学
旖-旎1 天前
FloodFill(图像渲染)(1)
c++·算法·深度优先·力扣
江屿风2 天前
C++图论基础拓扑排序经典OJ题流食般投喂
开发语言·c++·笔记·算法·图论
兰令水2 天前
leecodecode【树形DP】【2026.6.11打卡-java版本】
java·算法·深度优先
Lsk_Smion2 天前
力扣实训 _ [207].课程表/图论
数据结构·leetcode·图论
2601_961845423 天前
高考真题试卷电子版|2025高考全科试卷分类下载
考研·面试·蓝桥杯·远程工作·程序员创富·高考
一条大祥脚4 天前
ABC461 枚举|扫描线|动态前缀和|数论|dfs枚举子集
算法·深度优先
Momo__zz5 天前
零代码平台设计
算法·深度优先
山峰哥5 天前
VB事件驱动编程实战:从零到一搭建完整管理系统
前端·数据库·性能优化·深度优先·vb