我不是妹子

P1220 关路灯

@[larry2004](/space/show?uid=90972) 应该时按照当前区间长度转移不是顺序 大概是 ```cpp for(int len=2;len<=n;len++) { for(int srt=1;srt+len-1<=n;srt++) { 转移方程 } } ```
by xiaolou @ 2019-01-13 14:31:00


@[larry2004](/space/show?uid=90972) ~~不帮人调代码,告辞~~
by shadowice1984 @ 2019-01-13 14:32:59


@[xiaolou](/space/show?uid=68675) 然鹅并没有什么卵用 ```cpp #include<cstring> #include<cstdio> #include<iostream> using namespace std; int w[105],g[105]; int f[105][105][2]; int sum[105]; int main() { /*freopen(" ","r",stdin); freopen(" ","w",stdout);*/ int n,c; cin>>n>>c; for(int i=1;i<=n;i++) { cin>>w[i]>>g[i]; sum[i]=sum[i-1]+g[i]; } for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) { f[i][j][0]=0x777777; f[i][j][1]=0x777777; } f[c][c][0]=0; f[c][c][1]=0; for(int k=2;k<=n;k++) { for(int j=1;j+k-1<=n;j++) { int i=j+k-1; f[j][i][0]=min(f[j+1][i][0]+(w[j+1]-w[j])*(sum[n]-(sum[i]-sum[j])),f[j+1][i][1]+(w[i]-w[j])*(sum[n]-(sum[i]-sum[j]))); f[j][i][1]=min(f[j-1][i][0]+(w[i]-w[j])*(sum[n]-(sum[i-1]-sum[j-1])),f[j-1][i][1]+(w[i]-w[i-1])*(sum[n]-(sum[i-1]-sum[j-1]))); } } cout<<min(f[1][n][0],f[1][n][1]); /*fclose(stdin); fclose(stdout);*/ return 0; } ```
by shitbro @ 2019-01-13 14:33:34


@[larry2004](/space/show?uid=90972) 把第二个转移方程里面的f[j-1][i][1]改成f[j][i-1][1]试一下
by xiaolou @ 2019-01-13 14:38:18


@[xiaolou](/space/show?uid=68675) 谢谢巨佬, 我a了!!!!!!!!!!!!
by shitbro @ 2019-01-13 14:40:32


@[larry2004](/space/show?uid=90972) 不谢
by xiaolou @ 2019-01-13 14:41:40


才刚过来两分钟emm
by ButterflyDew @ 2019-01-13 14:42:42


@[ButterflyDew](/space/show?uid=63727) 您非常ju
by shitbro @ 2019-01-13 14:43:36


所以你为什么要强调你不是妹子呢?
by Kuriyama_Mirai @ 2019-01-13 14:51:06


上一页 |