# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
768520 | nguyentunglam | Two Dishes (JOI19_dishes) | C++17 | 29 ms | 32144 KiB |
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>
#define fi first
#define se second
#define endl "\n"
#define ii pair<int, int>
using namespace std;
const int N = 2010;
long long a[N], b[N], s[N], t[N], p[N], q[N];
long long f[N][N];
int main() {
#define task ""
cin.tie(0) -> sync_with_stdio(0);
if (fopen ("task.inp", "r")) {
freopen ("task.inp", "r", stdin);
freopen ("task.out", "w", stdout);
}
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int n, m; cin >> n >> m;
for(int i = 1; i <= n; i++) {
cin >> a[i] >> s[i] >> p[i];
a[i] += a[i - 1];
}
for(int i = 1; i <= m; i++) {
cin >> b[i] >> t[i] >> q[i];
b[i] += b[i - 1];
}
memset(f, -127, sizeof(f));
f[0][0] = 0;
for(int i = 0; i <= n; i++) for(int j = 0; j <= m; j++) {
if (i == 0 && j == 0) continue;
if (i) f[i][j] = max(f[i][j], f[i - 1][j] + (a[i] + b[j] <= s[i]) * p[i]);
if (j) f[i][j] = max(f[i][j], f[i][j - 1] + (a[i] + b[j] <= t[j]) * q[j]);
}
cout << f[n][m];
}
Compilation message (stderr)
# | 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... |