题目链接:登录 - 沐枫OJ
这个问题其实是比较复杂的演讲大厅安排(hall)问题,其实还是背包问题,而且题目很难理解,然后就是要判断要+c?是由距离决定的,所以中间要判断三次,然后就是dp[s] = 0,这点与其它背包问题不太一样
我的思路:
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int l1,l2,l3,c1,c2,c3,dp[5000],dist[207];
int main(){
int n,s,t;
memset(dp, 0x3F, sizeof dp); //设为无穷大
cin >> l1 >> l2 >> l3 >> c1 >> c2 >> c3;
cin >> n;
cin >> s >> t;//s起始站,t终点站
for(int i = 2;i <= n;i++){
cin >> dist[i];
}
if(s>t) swap(s,t); //保证s是小的
dp[s] = 0;
for(int i = s+1;i <= t;i++){
for(int j = s;j < i;j++){
if(dist[i]-dist[j]&l