Submission #715065

#TimeUsernameProblemLanguageResultExecution timeMemory
715065TrentCloud Computing (CEOI18_clo)C++17
0 / 100
16 ms2204 KiB
#include "bits/stdc++.h"

using namespace std;
#define forR(i, a) for(int i = 0; (i) < (a); ++(i))
#define REP(i, a, b) for(int i = (a); (i) < (b); ++i)
#define all(a) a.begin(), a.end()
#define boost() cin.sync_with_stdio(0); cin.tie(0)
#define printArr(arr) for(int asdfg : arr) cout << asdfg << ' '; cout << '\n'
typedef long long ll;
typedef array<int, 2> pii;
#define int ll

// computer: (+ cores, speed, + in profit)
struct thing{
    int c, f, v;
};
const int MN = 2e3 + 10, MC=60;
const ll INF = 1e15;
thing arr[2 * MN];

signed main(){
    int n; cin >> n;
    forR(i, n) {
        cin >> arr[i].c >> arr[i].f >> arr[i].v;
        arr[i].v *= -1;
    }
    int m; cin >> m;
    REP(i, n, n + m){
        cin >> arr[i].c >> arr[i].f >> arr[i].v;
        arr[i].c *= -1;
    }
    sort(arr, arr + n + m, [](thing& a, thing& b){return a.f > b.f;});
    vector<ll> pre(MN * MC, -INF), cur(MN * MC, -INF);
    pre[0] = 0; int cs=MN * MC;
    forR(i, n + m){
        forR(j, cs + 1) cur[j] = pre[j];
        forR(j, cs + 1) if(j + arr[i].c >= 0) cur[j + arr[i].c] = max(cur[j + arr[i].c], pre[j] + arr[i].v);
        // cs += max(0LL, arr[i].c);
        // forR(j, 20) cout << pre[j] << ' ';
        // cout << '\n';
        // forR(j, 20) cout << cur[j] << ' ';
        // cout << "\n\n";
        pre.swap(cur);
    }
    ll bes = 0;
    for(ll i : pre) bes = max(bes, i);
    cout << bes << '\n';
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...