Submission #1046388

#TimeUsernameProblemLanguageResultExecution timeMemory
1046388mrwangCloud Computing (CEOI18_clo)C++14
18 / 100
345 ms1972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 2000 + 5; const int inf = 1e17; vector<ll> last, curr; int n, m; vector<ll> c, f, v, type; bool cmp(const int &a, const int &b) { if (f[a] != f[b]) return f[a] > f[b]; return type[a] < type[b]; } int main() { int cores = 0; cin >> n; c.resize(4000); f.resize(4000); v.resize(4000); type.resize(4000); for(int i = 0; i < n; i++) { cin >> c[i] >> f[i] >> v[i]; type[i] = -1; cores += c[i]; } cin >> m; for(int i = 0; i < m; i++) { cin >> c[n + i] >> f[n + i] >> v[n + i]; type[n + i] = 1; } vector<int> j(n + m); for(int i=0;i<n+m;i++) j[i]=i; sort(j.begin(), j.end(), cmp); last.assign(cores + 5, -inf); curr.assign(cores + 5, -inf); last[0] = curr[0] = 0; for(const int &i : j) { curr = last; if(type[i] == -1) { for(int j = c[i]; j <= cores; j++) curr[j] = max(curr[j], last[j - c[i]] - v[i]); } else { for(int j = 0; j <= cores - c[i]; j++) curr[j] = max(curr[j], last[j + c[i]] + v[i]); } last.swap(curr); } cout << *max_element(last.begin(), last.end()); return 0; }

Compilation message (stderr)

clo.cpp:5:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+17' to '2147483647' [-Woverflow]
    5 | const int inf = 1e17;
      |                 ^~~~
#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...