Created
August 11, 2017 15:08
-
-
Save mi6112ogit/dc32dcf8dba7c8f44e66bb2f89a4f57d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <algorithm> | |
#include <utility> | |
#include <map> | |
#include <queue> | |
#include <string> | |
#include <vector> | |
#include <cstdio> | |
#include <cstring> | |
#include <cstdlib> | |
#include <ctime> | |
#include <cmath> | |
using namespace std; | |
#define FOR(i, j, k) for(int i = j; i < k; ++i) | |
#define rep(i, j) FOR(i, 0, j) | |
#define FORr(i, j, k) for(int i = j; i >= k; --i) | |
#define repr(i, j) FOR(i, j, 0) | |
#define gcd(x, y) int gcd(int x, int y) {return (y == 0) ? x : gcd(y, x % y);} | |
#define INF (1 << 30) | |
typedef long long ll; | |
typedef unsigned long long ull; | |
typedef pair<int, int> P; | |
typedef pair<int, P> Pi; | |
const int MOD = 1e9 + 7; | |
const int dy[]={0, 0, 1, -1}; | |
const int dx[]={1, -1, 0, 0}; | |
template <class T> void chmin(T& a, const T& b) { a = min(a, b); } | |
template <class T> void chmax(T& a, const T& b) { a = max(a, b); } | |
int dp[101]; | |
Pi input[100]; | |
int main() { | |
int n, k, t; | |
scanf("%d %d %d", &n, &k, &t); | |
rep(i, n) cin >> input[i].first; | |
rep(i, n) cin >> input[i].second.first; | |
rep(i, n) cin >> input[i].second.second; | |
sort(input, input + n); | |
rep(i, n + 1) dp[i] = -INF; | |
dp[0] = 0; | |
int res = 0; | |
FOR(i, 1, n + 1) rep(j, i) { | |
if(input[i - 1].first - input[j - 1].first >= abs(input[i - 1].second.second - input[j - 1].second.second)) { | |
chmax(dp[i], dp[j] + input[i - 1].second.first); | |
} | |
} | |
rep(i, n + 1) chmax(res, dp[i]); | |
printf("%d\n", res); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment