# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
152590 | Mercenary | Cloud Computing (CEOI18_clo) | C++14 | 396 ms | 1400 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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define mp make_pair
#define taskname "A"
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
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()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
if(fopen(taskname".INP","r")){
freopen(taskname".INP", "r",stdin);
freopen(taskname".OUT", "w",stdout);
}
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... |