제출 #591188

#제출 시각아이디문제언어결과실행 시간메모리
591188jackkkkCloud Computing (CEOI18_clo)C++11
18 / 100
500 ms1280 KiB
// Cloud Computing // https://oj.uz/problem/view/CEOI18_clo #include <stdio.h> #include <iostream> #include <string> #include <vector> #include <queue> #include <map> #include <array> #include <deque> #include <unordered_map> #include <unordered_set> #include <set> #include <algorithm> #include <stdlib.h> #include <math.h> #include <list> #include <float.h> #include <climits> #include <iomanip> #include <chrono> using namespace std; using namespace std::chrono; void quit() { cout.flush(); exit(0); } struct comp{ int c; long long p, v; }; const long long md = 1e9+7; const long long mx = 100001; long long dp[mx+1]; int main(void){ //freopen("qwer.in", "r", stdin); //freopen("qwer.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n; vector<comp> computers; comp tmp; for(int i = 0; i < n; i++){ cin >> tmp.c >> tmp.p >> tmp.v; tmp.v *= -1; computers.push_back(tmp); } cin >> m; for(int i = 0; i < m; i++){ cin >> tmp.c >> tmp.p >> tmp.v; tmp.c *= -1; computers.push_back(tmp); } sort(computers.begin(), computers.end(), [](comp a, comp b){ return a.p > b.p || (a.p == b.p && a.c > b.c); }); for(int i = 0; i <= mx; i++){ dp[i]=-10000000000000000LL; } dp[0]=0; for(comp computer : computers){ if(computer.c > 0){ for(int nm_cores = mx; nm_cores >= computer.c; nm_cores--){ int prev = nm_cores-computer.c; dp[nm_cores] = max(dp[nm_cores], dp[prev]+computer.v); } } else{ for(int nm_cores = 0; nm_cores <= mx + computer.c; nm_cores++){ int prev = nm_cores-computer.c; dp[nm_cores] = max(dp[nm_cores], dp[prev]+computer.v); } } } long long ans = 0; for(int i = 1; i <= mx; i++){ ans = max(ans, dp[i]); } cout << ans << "\n"; quit(); }
#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...