#include<bits/stdc++.h>
#define INF 2110000000
using namespace std;
int dp[3010][3010], i, j, k, l, n, m, s, e, t, A[3010][3010], B[3010], ans=2147483647;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for(cin>>n>>m>>s>>e>>t;i++<n;)
{
for(j=0;j++<m;)
{
cin>>A[i][j];
A[i][j]+=A[i][j-1];
}
}
for(i=0;i++<n;)cin>>B[i];
for(i=0;i++<n;)
{
for(j=0;j++<m;)
{
dp[i][j]=INF;
}
}
for(j=0;j++<m;)
{
for(i=0;i++<n;)
{
for(k=j-s;k>=j-e;k--)
{
if(k<0)continue;
for(l=0;l++<n;)
{
if(dp[l][k]==INF||(k&&l==i)||(k&&l==B[i]))continue;
dp[i][j]=min(dp[i][j], dp[l][k]+(k==0?0:t)+A[i][j]-A[i][k]);
}
}
}
}
for(i=0;i++<n;)ans=min(ans, dp[i][m]);
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
748 KB |
Output is correct |
2 |
Incorrect |
1 ms |
748 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |