이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |