# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580322 | juggernaut | Cloud Computing (CEOI18_clo) | C++14 | 148 ms | 524 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>
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
#define USING_ORDERED_SET 0
#if USING_ORDERED_SET
#include<bits/extc++.h>
using namespace __gnu_pbds;
template<class T>using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
#endif
template<class T>void umax(T &a,T b){if(a<b)a=b;}
template<class T>void umin(T &a,T b){if(b<a)a=b;}
#ifdef juggernaut
#define printl(args...) printf(args)
#else
#define printl(args...) 0
#endif
struct dat{
int core;
int freq;
int cost;
}a[4005];
int n,m;
bool cmp(dat l,dat r){
if(l.freq==r.freq)return l.cost<r.cost;
return l.freq>r.freq;
}
const int MX=25000;
ll dp[MX+5];
int main(){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
a[i].cost*=-1;
}
fill(dp,dp+MX+5,-1e15);
dp[0]=0;
scanf("%d",&m);
for(int i=n;i<n+m;i++)scanf("%d%d%d",&a[i].core,&a[i].freq,&a[i].cost);
sort(a,a+n+m,cmp);
for(int i=0;i<n+m;i++){
if(a[i].cost<0){
for(int j=MX;j>=a[i].core;j--)
umax(dp[j],dp[j-a[i].core]+a[i].cost);
}else{
for(int j=0;j<=MX-a[i].core;j++)
umax(dp[j],dp[j+a[i].core]+a[i].cost);
}
}
for(int i=1;i<=MX;i++)umax(dp[i],dp[i-1]);
cout<<dp[MX];
}
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... |