屁嘞,汉高祖终于绿名了
#include<bits/stdc++.h>
using namespace std;
#define L long long
L n, k, z[101], y[101], ans, r[1001];
L m[101];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> z[i];
r[i] = r[i - 1] + z[i];
}
for (int i = 1; i <= n - 1; i++) {
L s;
cin >> s;
y[i] = y[i - 1] + s;
}
L ll = k;
while (ll > 0) {
for (int i = 1; i <= n; i++) {
if (r[i] > (r[n] - r[i])) {
m[ll] = y[i];
break;
}
}
ll--;
}
for (int i = 1; i <= n; i++) {
L mn = 1e9;
for (int j = 1; j <= k; j++) {
mn = min(abs((y[i] - m[j])), mn);
}
ans += mn * z[i];
}
cout << ans;
return 0;
}