CF6D Lizards and Basements 2
题意:有n个人,编号1到n,每个人有血量 h i h_i hi对某个人攻击会产生a点伤害,会波及到相邻的人,对相邻的人产生b点伤害(1和n号人不能攻击),问最少要攻击多少次才能让所有人的h小于0,分别攻击了谁。
解法:dfs搜索,先处理出每个人最多攻击多少次,对攻击次数枚举,每次保证当前点前所有人h值已经小于0。
代码:
#include<bits/stdc++.h>
using namespace std;
const int N = 20;
int n, a, b, h[N], ci[N], tmp[N];
int res = 1e9