Submission #1362677

#TimeUsernameProblemLanguageResultExecution timeMemory
1362677TsotneSVCloud Computing (CEOI18_clo)C++20
0 / 100
354 ms327680 KiB
#include <bits/stdc++.h>
using namespace std;
/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⠀⠀⠀⠀⠀⠀⠀⡄⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣿⠛⣿⠀⠀⠀⠀⣤⣿⢻⡇⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣤⣿⡛⠀⣤⣿⣿⣤⣤⣿⣿⣤⢸⡇⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣴⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠀
⠀⠀⠀⠀⠀⠀⠀⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡗⠀
⢠⣼⣿⣿⣿⣿⣤⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷
⢸⣿⣿⡟⠛⠛⢿⣿⣿⣿⣿⣿⣿⣿⣤⣤⣤⣿⣿⣿⣿⣤⣤⣼⣿⣿
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠋       
*/
#define fi first
#define se second
#define pb push_back
#define ins insert
#define sz(a) (int)(a.size())
#define all(x) (x).begin(),(x).end()
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

#define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#endif

//const int mod = 1e9+7;
//const int mod = 998244353;
const int MAXN=2e5+5,MAX_CORES = 50 * 2000 + 5; 
const ll inf=1e9,INF=1e18; 

int n,m;

using T = array<int,3>;

void solve(int tc = 0){
    cin>>n; vector<T> G;

    rep(i,1,n+1) {
        int c,f,v; cin>>c>>f>>v;
        G.pb({f,c,-v});
    }

    cin>>m;

    rep(i,1,m+1) {
        int c,f,v; cin>>c>>f>>v;
        G.pb({f,-c,v});
    }

    sort(all(G),greater<T>());

    int L = n + m; vector<vector<ll>> dp(MAX_CORES,vector<ll>(L + 1,-INF));

    dp[0][0] = 0; ll ans = 0;

    rep(i,1,L+1) {

        auto [f,c,v] = G[i-1];

        rep(cores,0,MAX_CORES) {
            dp[cores][i] = dp[cores][i-1];
            if(cores - c >= MAX_CORES or cores - c < 0) continue;
            dp[cores][i] = max(dp[cores][i],dp[cores-c][i-1] + v);
            ans = max(ans,dp[cores][i]);
        }

    }

    print(ans);
}

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(0);

    int tc=1;
    //cin>>tc;
    for(int t = 0; t < tc; t++) solve(t);
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...