Submission #1092171

# Submission time Handle Problem Language Result Execution time Memory
1092171 2024-09-23T12:44:36 Z vu28082007 Holding (COCI20_holding) C++14
0 / 110
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
int n, l, r, k, a[107];
int main() 
{
    cin >> n >> l >> r >> k;
    for (int i = 1; i <= n; i++)
    {
      cin >> a[i];
    }
    int m = (r-l+1);
    int res=1e9;
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(m+1, vector<int>(k+1, 1e9)));
    for (int i = 0; i <= n; i++)
    {
      for (int j = 0; j <= k; j++)
      {
        dp[i][0][j]=0;
      }
    }
    for (int i = 1; i <= n; i++)
    {
      for (int j = 1; j <= m; j++)
      {
        for (int p = 0; p <= k; p++)
        {
          dp[i][j][p]=dp[i-1][j][p];
          if(p-(i-abs(j+l-1)) >= 0)
          {
            dp[i][j][p]=min(dp[i][j][p], dp[i-1][j-1][p-(i-abs(j+l-1))] + a[i]);
          }
          if(j==m)
          {
            res=min(res, dp[i][m][p]);
          }
        }
      }
    }
    cout << res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -