样例怎么算出270的

P1220 关路灯

还有程序有啥错误的。。。 ``` #include<bits/stdc++.h> using namespace std; int n,c,zz,yy,t,su[10005][55][55]; struct p{ int w,g; }a[55]; int dfs(int wz,int z,int y){int th=1e9; if(su[wz][z][y])return su[wz][z][y];if(z==0&&y==0)return 0; if(z>0)t+=abs(wz-a[z].w),th=min(th,dfs(a[z].w,z-1,y)+t*a[z].g),t-=abs(wz-a[z].w); if(y>0)t+=abs(wz-a[n-y+1].w),th=min(th,dfs(a[n-y+1].w,z,y-1)+t*a[n-y+1].g),t-=abs(wz-a[n-y+1].w); return su[wz][z][y]=th; } int main(){ cin>>n>>c;for(int i=1;i<=n;i++){cin>>a[i].w>>a[i].g;if(a[i].w<c)zz++;if(a[i].w>c)yy++;} cout<<dfs(c,zz,yy); return 0; } ```
by 沉鸣cmh @ 2020-08-30 20:32:13


题目中给的初始位置是在第几个路灯,而不是直接给的x坐标
by Tirpitz__ @ 2021-10-30 08:09:15


@[Tirpitz__](/user/64974) 感谢 我是sb
by CNCAGN @ 2023-10-26 15:26:41


|