제출 #1019994

#제출 시각아이디문제언어결과실행 시간메모리
1019994michifiedCloud Computing (CEOI18_clo)C++17
36 / 100
120 ms262144 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; struct spec_t { int c, s; ll v; }; int main() { int n, m, i, j, ccnt = 0; cin >> n; vector<spec_t> specs; for (i = 0; i < n; i++) { specs.push_back({0, 0, 0}); cin >> specs[i].c >> specs[i].s >> specs[i].v; ccnt += specs[i].c; specs[i].v = -specs[i].v; } cin >> m; for (i = n; i < m + n; i++) { specs.push_back({0, 0, 0}); cin >> specs[i].c >> specs[i].s >> specs[i].v; specs[i].c = -specs[i].c; } specs.push_back({0, INT_MAX, 0}); sort(specs.begin(), specs.end(), [](const spec_t& a, const spec_t& b){return a.s == b.s ? a.v < b.v : a.s > b.s;}); int t = n + m + 1; vector<vector<ll>> dp(t, vector<ll>(ccnt + 1, LLONG_MIN)); dp[0][0] = 0; for (i = 1; i < t; i++) { for (j = 0; j <= ccnt; j++) { dp[i][j] = dp[i - 1][j]; int prev = j - specs[i].c; if (prev >= 0 and prev <= ccnt and dp[i - 1][prev] != LLONG_MIN) dp[i][j] = max(dp[i][j], dp[i - 1][prev] + specs[i].v); } } cout << *max_element(dp[t - 1].begin(), dp[t - 1].end()); 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...