Submission #996939

#TimeUsernameProblemLanguageResultExecution timeMemory
996939aykhnCloud Computing (CEOI18_clo)C++17
100 / 100
1265 ms7164 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define inf 0x3F3F3F3F3F3F3F3F const int MXN = 3e5 + 5; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<array<int, 3>> a(n); for (array<int, 3> &i : a) { cin >> i[1] >> i[0] >> i[2]; i[2] = -i[2]; } int m; cin >> m; for (int i = 0; i < m; i++) { array<int, 3> x; cin >> x[1] >> x[0] >> x[2]; x[1] = -x[1]; a.push_back(x); } sort(a.rbegin(), a.rend()); int s = 0; vector<int> ndp, dp = {0}; for (array<int, 3> &x : a) { s += abs(x[1]); ndp.assign(s + 1, -inf); for (int i = 0; i < dp.size(); i++) { ndp[i] = max(ndp[i], dp[i]); if (i + x[1] >= 0) ndp[i + x[1]] = max(ndp[i + x[1]], dp[i] + x[2]); } swap(ndp, dp); } cout << *max_element(dp.begin(), dp.end()) << '\n'; }

Compilation message (stderr)

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