mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
7a2a9109f5
2600-2699
33 lines
716 B
C++
33 lines
716 B
C++
#include <cstdio>
|
|
#include <cstring>
|
|
#include <algorithm>
|
|
#define max(a,b) ( a>b ? a:b )
|
|
using namespace std;
|
|
struct ha
|
|
{
|
|
int a, b;
|
|
} s[1111];
|
|
int haha ( ha a, ha b )
|
|
{
|
|
return a.b > b.b;
|
|
}
|
|
int main ()
|
|
{
|
|
int i, j, k;
|
|
int n, m, v;
|
|
int dp[1111];
|
|
while ( ~scanf ("%d %d", &n, &m) )
|
|
{
|
|
memset ( dp, 0, sizeof (dp));
|
|
for ( i=0 ; i<n ; i++ )
|
|
scanf ("%d", &s[i].a);
|
|
for ( i=0 ; i<n ; i++ )
|
|
scanf ("%d", &s[i].b);
|
|
sort (s, s+n, haha);
|
|
for ( i=0 ; i<n ; i++ )
|
|
for ( j=m ; j>0 ; j-- )
|
|
dp[j] = max (dp[j], dp[j-1]+s[i].a-(j-1)*s[i].b);
|
|
printf ("%d\n" ,dp[m]);
|
|
}
|
|
}
|