Submission #400337

#TimeUsernameProblemLanguageResultExecution timeMemory
400337abdzagCloud Computing (CEOI18_clo)C++17
0 / 100
29 ms3020 KiB
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define  sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(false);
    ll n,m;
    cin >> n;
    vector<pair<pair<ll, ll>, pair<ll, ll>>> v(n);
    rep(i, 0, n) {
        cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
        v[i].first.first *= -1;
    }
    cin >> m;
    v.resize(n + m);
    rep(i, n, n+m) {
        cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
        v[i].first.first *= -1;
        v[i].first.second = 1;
    }
    sort(all(v));
    map<ll,ll> dp;
    rep(i, -1000, 10000)if (i)dp[i] = -inf;
    trav(a, v)cout << a.first.first << " " << a.first.second << " " << a.second.first << " " << a.second.second << endl;
    map<ll,ll> dp0=dp;
    map<ll, ll> dp2 = dp;
    map<ll, ll> dp20 = dp;

    rep(i, 0, n+m) {
        rep(j, 0, 10000) {
            if (!v[i].first.second) {
                if (dp0[j] != -inf)dp[v[i].second.first + j] = max(dp0[v[i].second.first + j], dp0[j]-v[i].second.second);
            }
            else {
                if (dp0[j] != -inf)dp[-v[i].second.first + j] = max(dp0[-v[i].second.first + j], dp0[j] + v[i].second.second);

            }
        }
        dp0 = dp;
    }
    ll ans = 0;
    rep(i, 0, 1e4 + 1)ans = max(dp[i], ans);
    cout<<ans;
    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...