This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e18;
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int nbLig, nbCol;
  cin >> nbLig >> nbCol;
  vector<int> deltaCol(nbLig), deltaLig(nbCol);
  for (int &x : deltaCol)
    cin >> x;
  for (int &x : deltaLig)
    cin >> x;
  vector<vector<int>> dp(nbLig, vector<int>(nbCol, INF));
  for (int lig = nbLig - 1; lig >= 0; --lig) {
    for (int col = nbCol - 1; col >= 0; --col) {
      if (lig == nbLig - 1) {
        dp[lig][col] = (nbCol - 1 - col) * deltaCol[lig];
      } else {
        dp[lig][col] = deltaLig[col] + dp[lig + 1][col];
        if (col < nbCol - 1)
          dp[lig][col] = min(dp[lig][col], deltaCol[lig] + dp[lig][col + 1]);
      }
    }
  }
  cout << dp[0][0] << endl;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |