제출 #1126908

#제출 시각아이디문제언어결과실행 시간메모리
1126908woodCloud Computing (CEOI18_clo)C++20
0 / 100
132 ms25928 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vi vector<int>
#define vp32 vector<p32>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MOD %1000000007
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
using Tree =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//never guess
//never debug without reviewing code
//never try adding ones or substracting them
//only step by step debug when necessay



void solve(){
    int n; cin>>n;
    vector<tuple<int,int,int>> trans;
    for (int i = 0; i < n; ++i) {
        int c,f,v; cin>>c>>f>>v;
        trans.emplace_back(f,c,-v);
    }
    cin>>n;
    for (int i = 0; i < n; ++i) {
        int c,f,v; cin>>c>>f>>v;
        trans.emplace_back(f,-c,v);
    }
    sort(trans.begin(),trans.end(),greater<>());
    n = trans.size();
    int N = 1e5+10;
    ll dp[n+1][N]; fill(dp[0],dp[0]+N*n+N,-1e12);
    for(int i = 0; i<n; i++){
        dp[i][0] = 0;
        dp[i+1][0] = 0;
        int a,c,v; tie(a,c,v) = trans[i];
        for (int j = 0; j<N; j++) {
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            if(j+c>=0&&j+c<N){
                dp[i+1][j+c] = max(dp[i+1][j+c],dp[i][j]+(ll)v);
            }
        }
    }
    ll res = 0;
    for(int i = 0; i<N; i++){
        res = max(res,dp[n][i]);
        cout<<dp[n][i]<<endl;
    }
    cout<<res<<'\n';
}
int main()
{
    fast_cin();
    #ifndef ONLINE_JUDGE
        //freopen("input.in", "r", stdin);
    #endif
        int t = 1;
    while(t--){
        solve();
    }
    return 0;
}
#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...