# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
358557 | Sparky_09 | Cloud Computing (CEOI18_clo) | C++17 | 401 ms | 1388 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
void usaco(string s){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
const int maxn = 2e3 + 5;
ll dp[maxn * 50];
struct object{
int c , f , v;
bool operator < (const object & other){
if(f == other.f)return v < other.v;
return f > other.f;
}
}a[maxn * 2];
int n , m;
int main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
#ifdef LOCAL_DEFINE
freopen("input.txt", "r", stdin);
#endif
cin >> n;
for(int i = 1 ; i <= n ; ++i){
cin >> a[i].c >> a[i].f >> a[i].v;
a[i].v = -a[i].v;
}
cin >> m;
for(int i = 1 ; i <= m ; ++i){
cin >> a[i + n].c >> a[i + n].f >> a[i + n].v;
}
sort(a + 1 , a + n + m + 1);
fill_n(&dp[0],maxn*50,-1e18);
dp[0] = 0;
for(int i = 1 ; i <= n + m ; ++i){
if(a[i].v < 0){
for(int j = 100000 - a[i].c ; j >= 0 ; --j){
dp[j + a[i].c] = max(dp[j + a[i].c] , dp[j] + a[i].v);
}
}else{
for(int j = a[i].c ; j <= 100000 ; ++j){
dp[j - a[i].c] = max(dp[j - a[i].c] , dp[j] + a[i].v);
}
}
}
cout << *max_element(dp,dp+maxn*50);
}
Compilation message (stderr)
# | 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... |