Submission #398782

#TimeUsernameProblemLanguageResultExecution timeMemory
398782VictorCloud Computing (CEOI18_clo)C++17
100 / 100
1130 ms2920 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = a; i < (b); ++i) #define per(i, a, b) for (int i = b - 1; i >= (a); --i) #define trav(a, x) for (auto &a : x) #define all(x) x.begin(), x.end() #define sz(x) x.size() #define pb push_back #define umap unordered_map #define uset unordered_set typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef long long ll; const int INF = 1000000007; int main() { int n, m, c; vector<pair<ii, pair<ll, int>>> dpvec; ll f, v, sumc = 1, ans = 0; cin >> n; rep(i, 0, n) { scanf("%d %lld %lld",&c,&f,&v); dpvec.push_back({{f, 1}, {v, c}}); sumc += c; } cin >> m; rep(i, 0, m) { scanf("%d %lld %lld",&c,&f,&v); dpvec.push_back({{f, 0}, {v, c}}); } sort(all(dpvec), greater<>()); vector<ll> dummy(sumc, -1e15), dp = dummy, dp2 = dp; dp[0] = 0; trav(item, dpvec) { int query; tie(f, query) = item.first; tie(v, c) = item.second; rep(i, 0, sumc) { if (dp[i] == -1e15) continue; dp2[i] = max(dp2[i], dp[i]); if (query) dp2[i + c] = max(dp2[i + c], dp[i] - v); else if (!query && c <= i) dp2[i - c] = max(dp2[i - c], dp[i] + v); } dp.swap(dp2); dp2 = dummy; } trav(val, dp) ans = max(ans, val); printf("%lld\n",ans); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |         scanf("%d %lld %lld",&c,&f,&v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |         scanf("%d %lld %lld",&c,&f,&v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...