深搜会T吧,大概是2^n级
by MLE_Automaton @ 2024-10-25 21:08:48
正在做部分分练习
by yzdcm @ 2024-10-25 21:09:29
@[ChenXiJie2013](/user/928418) hui
by yzdcm @ 2024-10-25 21:13:54
```cpp
//深搜
#include<iostream>
#include<cstdio>
using namespace std;
struct LUDENGQINGKUANG{
int loc,ene,swi=1;//loc位置,ene能耗,swi开关 (1开,0关)
}ld[51];
int n,c,sum_ene=100000000;
void go(int t,int w,int c,int se){
if(wm==1){
sum_ene=min(sum_ene,se);
return;
}
ld[c].swi=0;
if(c>0){
if(ld[c-1].swi==1){
go(t+c-ld[c-1].loc,w-1,ld[c-1].loc,se+t*ld[c].ene);
}
}
if(c<n){
if(ld[c+1].swi==1){
go(t+ld[c+1].loc-c,w-1,ld[c-1].loc,se+t*ld[c].ene);
}
}
}
int main(){
//freopen("turnoff.in","r",stdin);
//freopen("turnoff.out","w",stdout);
cin>>n>>c;
for(int i=1;i<=n;i++){
cin>>ld[i].loc>>ld[i].ene;
}
go(0,n,c,0)
return 0;
}
```
又写了点
by yzdcm @ 2024-10-25 21:16:27