/* Once we see the range of N and K and the type of the question, we should think of the relationship with DP, first sort by Bi from large to small (descending and quick early election, here is the greedy idea) DP [I] [J] indicates that the first I took the maximum value that can be reached by J, then the transfer equation is DP [I] [J] = max (DP [I-1] [J], DP [I-1] [J-1] + AI-(J-1) * bi ); */# include <vector> # include <map> # include <set> # include <deque> # include <stack> # include <bitset> # include <algorithm> # include <functional> # include <numeric> # include <utility> # include <sstream> # include <iostream> # include <iomanip> # include <cstdio> # include <queue> # I Nclude <cmath> # include <cstdlib> # include <cstring> # include <ctime> # include <string> using namespace STD; int N, K; struct point {int, b;} p [100009]; bool CMP (point X, point y) {return X. b> Y. b;} int DP [100009] [1009]; int main () {While (scanf ("% d", & N, & K )! = EOF) {for (INT I = 1; I <= N; I ++) scanf ("% d", & P [I]. a); For (INT I = 1; I <= N; I ++) scanf ("% d", & P [I]. b); Int J = 0, ANS = 0; sort (p + 1, P + n + 1, CMP); For (INT I = 0; I <= N; I ++) DP [I] [0] = 0; For (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= I & J <= K; j ++) DP [I] [J] = max (DP [I-1] [J], DP [I-1] [J-1] + (P [I]. a-(J-1) * P [I]. b);} printf ("% d \ n", DP [N] [k]);}