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;
using lli = long long;
const int MAXN = 1e2 + 10;
lli dp[MAXN][MAXN][MAXN];
pair<lli, lli> xs[MAXN], ys[MAXN];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, t;
cin >> n >> m >> t;
for (int i = 1; i <= n; ++i)
cin >> xs[i].first >> xs[i].second;
for (int i = 1; i <= m; ++i)
cin >> ys[i].first >> ys[i].second;
sort(xs+1, xs+n+1);
sort(ys+1, ys+m+1, [](pair<int, int> a, pair<int, int> b) { return a.second < b.second; });
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= m; ++j)
for (int z = 1; z <= t; ++z){
dp[i][j][z] = max(dp[i][j-1][z], dp[i-1][j][z]);
if (xs[i].second >= ys[j].second)
dp[i][j][z] = max(dp[i][j][z], dp[i-1][j-1][z-1] - xs[i].first + ys[j].first);
}
cout << dp[n][m][t] << 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... |
# | 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... |