|
|
back to boardwhy WA #8??? help me I already change start and finish points but still WA #8…… this is my coad #include<iostream> using namespace std; const int maxn=10005; long long f[maxn][maxn]; int cost[4]; int d[4]; int a[maxn]; int main() { freopen("in.txt","r",stdin); for(int i=1;i<=3;i++) cin>>d[i]; for(int i=1;i<=3;i++) cin>>cost[i]; int n; cin>>n; for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) f[i][j]=INT_MAX; int s,e; cin>>s>>e; for(int i=2;i<=n;i++) { cin>>a[i]; int temp=a[i]-a[i-1]; if(temp>d[2]) temp=cost[3]; else if(temp>d[1]) temp=cost[2]; else temp=cost[1]; f[i-1][i]=temp; } for(int i=1;i<=n;i++) f[i][i]=0; for(int p=2;p<=n;p++) for(int i=1;i<=n-p;i++) for(int j=i+1;j<=i+p;j++) { int k=1; while(1) { if(j-k<=i) break; if(a[j]-a[j-k]>d[3])break; if(a[j]-a[j-k]>d[2]) f[i][j]=min(f[i][j],f[i][j-k]+cost[3]); else if(a[j]-a[j-k]>d[1]) f[i][j]=min(f[i][j],f[i][j-k]+cost[2]); else f[i][j]=min(f[i][j],f[i][j-k]+cost[1]); k++; } k=1; while(1) { if(i+k>=j) break; if(a[i+k]-a[i]>d[3]) break; if(a[i+k]-a[i]>d[2]) f[i][j]=min(f[i][j],f[i+k][j]+cost[3]); else if(a[i+k]-a[i]>d[1]) f[i][j]=min(f[i][j],f[i+k][j]+cost[2]); else f[i][j]=min(f[i][j],f[i+k][j]+cost[1]); k++; } } int aaa=min(s,e); int bbb=max(e,s); cout<<f[aaa][bbb]<<endl; return 0; } Re: why WA #8??? help me i think you should solve it yourself..we got wronganswer because of bad thinking habit Re: why WA #8??? help me try this test case: 1 2 3 1 2 3 2 2 1 1 ans = 1 Edited by author 30.10.2014 08:37 |
|
|