Submission #858991

#TimeUsernameProblemLanguageResultExecution timeMemory
858991BvoJaCloud Computing (CEOI18_clo)C++11
18 / 100
323 ms1496 KiB
/**      />  フ      |  _  _|      /`ミ _x 彡      /      |     /  ヽ   |  / ̄|   | | |  | ( ̄ヽ__ヽ_)_)  \二つ **/ #include<bits/stdc++.h> #define ll long long #define pii pair<int, int> #define fi first #define se second #define Pt Point #define ALL(v) v.begin(), v.end() #define pb push_back #define MP make_pair #define MT make_tuple #define typeT tuple<int, int, int> #define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; i++) #define FOD(i, a, b) for (int i = (a), _b = (b); i >= _b; i--) #define MASK(i) (1 << (i)) #define BIT(k, i) (((k) >> (i)) & 1) const int N = 2e3 + 5; const int M = 1e5; using namespace std; int n, m; ll dp[M + 5]; struct Computer { int c, f, v; bool operator < (const Computer &other) const { if (f != other.f) return f > other.f; return c > other.c; } } a[N]; bool Maximize(ll &a, ll b) { if (a < b) { a = b; return true; } return false; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "a" //freopen(task".inp", "r", stdin); //freopen(task".out", "w", stdout); cin >> n; FOR(i, 1, n) { int c, f, v; cin >> c >> f >> v; a[i] = {c, f, -v}; } cin >> m; FOR(i, 1, m) { int c, f, v; cin >> c >> f >> v; a[++n] = {-c, f, v}; } sort(a + 1, a + 1 + n); memset(dp, -0x3f, sizeof dp); dp[0] = 0; FOR(i, 1, n) { int c = a[i].c, v = a[i].v; if (c > 0) { FOD(j, M - c, 0) Maximize(dp[j + c], dp[j] + v); } else FOR(j, -c, M + c) Maximize(dp[j + c], dp[j] + v); } ll res = 0; FOR(j, 0, M) Maximize(res, dp[j]); cout << res; 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...