Submission #617627

#TimeUsernameProblemLanguageResultExecution timeMemory
617627usuyusCloud Computing (CEOI18_clo)C++14
54 / 100
309 ms1260 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<array<ll, 3>> pts; int s = 0; for (int i=0; i<n; i++) { ll c, v, f; cin >> c >> f >> v; pts.push_back({f, c, -v}); s += c; } int m; cin >> m; for (int i=0; i<m; i++) { ll c, v, f; cin >> c >> f >> v; pts.push_back({f, c, v}); } sort(pts.rbegin(), pts.rend()); vector<ll> dp(s+1, -1e18); dp[0] = 0; for (auto [f, c, v] : pts) { // cout << f << ' ' << c << ' ' << v << endl; if (v > 0) { // cust for (int i=c; i<=s; i++) { dp[i - c] = max(dp[i - c], dp[i] + v); } } else { // comp for (int i=s-c; i>=0; i--) { dp[i + c] = max(dp[i + c], dp[i] + v); } } } ll ans = 0; for (ll x : dp) ans = max(ans, x); cout << ans << endl; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:29:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   29 |  for (auto [f, c, v] : pts) {
      |            ^
#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...