제출 #709980

#제출 시각아이디문제언어결과실행 시간메모리
709980OzyCloud Computing (CEOI18_clo)C++17
100 / 100
460 ms1484 KiB
#include <iostream> #include <bits/stdc++.h> using namespace std; #define lli long long int #define debug(a) cout << #a << " = " << a << endl #define debugsl(a) cout << #a << " = " << a << ", " #define rep(i,a,b) for(int i = (a); i <= (b); i++) #define repa(i,a,b) for(int i = (a); i >= (b); i--) #define pll pair<lli,lli> #define MAX 2000 #define frec first.first #define tipo first.second #define core second.first #define val second.second vector<pair<pll,pll > > orden; lli n,q,a,b,c,tam,res; lli dp[100002]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); rep(i,1,100000) dp[i] = -(1ll<<60); // numerp 1 son las computadoras cin >> n; rep(i,1,n) { cin >> a >> b >> c; orden.push_back({{b,1},{a,c}}); } // numerp 0 son las ventascin >> n; cin >> q; rep(i,1,q) { cin >> a >> b >> c; orden.push_back({{b,0},{a,c}}); } sort(orden.begin(), orden.end()); reverse(orden.begin(), orden.end()); tam = 0; res = 0; for(auto act : orden) { if (act.tipo == 0) { //es una venta rep(i,0,tam-act.core) { a = dp[i+act.core] + act.val; /*debugsl(i); debugsl(act.tipo); debugsl(tam); debugsl(act.core); debug(a);*/ dp[i] = max(dp[i],a); res = max(res,a); } } else { repa(i,tam,0) { a = dp[i] - act.val; dp[i+act.core] = max(dp[i+act.core],a); } tam += act.core; } } cout << res; 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...