# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
631872 | Blossomstream | Cloud Computing (CEOI18_clo) | C++14 | 0 ms | 0 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>
using namespace std;
using ll = long long;
int n, m;
ll dp[4000][100001];
pair<int, pair<ll, int> > c[4000];
int main() {
cin >> n;
int s = 0;
for(int i = 0; i < n; i++) {
cin >> c[i].second.second >> c[i].first >> c[i].second.first;
c[i].second.first = -c[i].second.first;
s += c[i].second.second;
}
cin >> m;
for(int i = 0; i < m; i++) {
cin >> c[i+n].second.second >> c[i+n].first >> c[i+n].second.first;
c[i+n].second.second = -c[i+n].second.second;
}
sort(begin(c), begin(c) + (n + m));
if(c[m+n-1].second.second > 0) {
for(int j = 1; j <= c[m+n-1].second.second; j++) {
dp[m+n-1][j] = c[m+n-1].second.first;
}
for(int j = c[m+n-1].second.second + 1; j <= s; j++) {
dp[m+n-1][j] = LONG_LONG_MIN;
}
} else {
for(int j = 0; j < s; j++) {
dp[m+n-1][j] = LONG_LONG_MIN;