제출 #1319099

#제출 시각아이디문제언어결과실행 시간메모리
1319099aaaaaaaaCloud Computing (CEOI18_clo)C++17
54 / 100
3092 ms1848 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops,Ofast") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt,tune=native") #define all(x) x.begin(), x.end() vector<vector<int>> v; signed main(){ ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); int n, m, cores = 0; cin >> n; for(int i = 0, a, b, c; i < n; ++i){ cin >> a >> b >> c; v.push_back({b, 1, a, c}); cores += a; } cin >> m; for(int i = 0, a, b, c; i < m; ++i){ cin >> a >> b >> c; v.push_back({b, 0, a, c}); cores += a; } sort(all(v), greater<>()); vector<long long> dp(cores + 2, 0); for(int i = v.size() - 1; i >= 0; --i){ if(v[i][1] == 1){ for(int j = 0; j <= cores; ++j){ if(j + v[i][2] <= cores) dp[j] = max(dp[j], (long long) dp[j + v[i][2]] - v[i][3]); } }else{ for(int j = cores; j >= 0; --j){ if(v[i][2] <= j) dp[j] = max(dp[j], (long long) dp[j - v[i][2]] + v[i][3]); } } } cout << dp[0] << "\n"; return 0; }
#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...