Submission #1085510

#TimeUsernameProblemLanguageResultExecution timeMemory
1085510juicyCloud Computing (CEOI18_clo)C++17
100 / 100
267 ms1620 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<long long> dp((n + 1) * 50 + 1, -1e18); vector<array<int, 4>> events; while (n--) { int a, b, c; cin >> a >> b >> c; events.push_back({b, 1, a, c}); } int m; cin >> m; while (m--) { int a, b, c; cin >> a >> b >> c; events.push_back({b, 0, a, c}); } sort(events.rbegin(), events.rend()); dp[0] = 0; for (auto [b, t, a, c] : events) { if (t == 0) { for (int i = 0; i < dp.size() - a; ++i) { dp[i] = max(dp[i], dp[i + a] + c); } } else { for (int i = dp.size() - 1; i >= a; --i) { dp[i] = max(dp[i], dp[i - a] - c); } } } cout << *max_element(dp.begin(), dp.end()); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:30:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |       for (int i = 0; i < dp.size() - a; ++i) {
      |                       ~~^~~~~~~~~~~~~~~
#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...