#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,x,y) for(ll i=x; i<y; i++)
#define FORNEG(i,x,y) for(ll i=x; i>y; i--)
using namespace std;
ll dp[250005][205];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
FOR(i,0,250005)FOR(j,0,205) dp[i][j] = -100000000000000000;
ll n,k;
cin >> n >> k;
vector<ll> price(n), sell(n);
FOR(i,0,n) cin >> price[i];
FOR(i,0,n) cin >> sell[i];
FOR(i,0,n) dp[i][0] = 0, dp[i][1] = sell[i]-price[i];
FOR(i,1,n+1){
FOR(j,2,205){
dp[i][j] = max(dp[i-1][j-1] + sell[i] - price[i], dp[i-1][j] - price[i]);
}
}
ll ans = -100000000000000000;
FOR(i,k,n+1){
ans = max(ans, dp[i][k]);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
401488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
401604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
401604 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
401380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
144 ms |
401380 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
140 ms |
401488 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |