This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define cl(a,s) memset((a),0,sizeof((a)[0])*(s))
#define all(x) (x).begin() , (x).end()
#define fi first
#define se second
#define int long long
using pii = pair<int,int>;
using ll = long long;
const int maxn = 2005;
const int inf = 1e9;
const int mod = 1e9+7;
int n,m;
int dp[maxn][maxn],c1[maxn],f1[maxn],cost1[maxn],c2[maxn],f2[maxn],cost2[maxn];
int32_t main () {
//freopen("in","r",stdin); freopen("out","w",stdout);
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
cin >> n;
for(int i=1;i<=n;i++) cin >> c1[i] >> f1[i] >> cost1[i];
cin >> m;
for(int i=1;i<=n;i++) cin >> c2[i] >> f2[i] >> cost2[i];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++) {
dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
if(cost1[i] < cost2[j] and f1[i] >= f2[j] and c1[i] >= c2[j])
dp[i][j] = max(dp[i][j],cost2[j]-cost1[i]+dp[i-1][j-1]);
}
cout << dp[n][m] << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |