做法
模拟费用流 网络流?数据范围显然不ok n2的边 哦? 居然是个dp
dp[i][j] 前i条边 j条边属于s集的 最小割
转移的话 如果 新加第i条边 可以割掉其与t集合的边
dp[i][j]=dp[i-1][j-1]+s[i]
另一种是割掉 s集的边 和比他编号小的边
dp[i][j]=dp[i-1][j]+p[i]+c*j;
开滚动数组优化
第一次做这种
//模拟费用流 网络流? 哦? 居然是个dp
//dp[i][j] 前i条边 j条边属于s集的 最小割
// 转移的话 如果 新加第i条边 可以割掉其与t集合的边
// dp[i][j]=dp[i-1][j-1]+s[i]
// 另一种是割掉 s集的边 和比他编号小的边
// dp[i][j]=dp[i-1][j]+p[i]+c*j;
#include <bits/stdc++.h>
using namespace std;
//#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define fi first
#define se second
#define pb push_back
#define inf 1ll<<60
#define endl "\n"
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define de_bug(x) cerr << #x << "=" << x << endl
#define all(a) a.begin(),a.end()
#define IOS std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fer(i,a,b) for(int i=a;i<=b;i++)
#define der(i,a,b) for(int i=a;i>=b;i--)
const int mod = 1e9 + 7;
const int N = 1e4 + 10;
ll n, m , k;
ll dp[2][N];
ll p[N];
ll s[N];
void solve() {
cin >> n >> k;
fer(i, 1, n)cin >> p[i];
fer(i, 1, n)cin >> s[i];
fer(i, 1, n)dp[1][i] = inf;
fer(i, 1, n) {
dp[0][0] = dp[1][0] + p[i];
for(int j = 1; j <= i; j++)dp[0][j] = min(dp[1][j - 1] + s[i], dp[1][j] + p[i] + k * j);
for(int j = 0; j <= i; j++)dp[1][j] = dp[0][j];
}
ll ans = inf;
for(int i = 0; i <= n; i++)ans = min(ans, dp[1][i]);
cout << ans << endl;
}
int main() {
IOS;
int _ = 1;
//cin>>_;
while( _-- )
solve();
}