Submission #713553

#TimeUsernameProblemLanguageResultExecution timeMemory
713553NNerverCloud Computing (CEOI18_clo)C++14
18 / 100
415 ms1256 KiB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5 + 10;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int MOD = 1e9+7;

long long dp[MAXN];
bool mark[MAXN];
int N,M;
vector<pair<int,pair<int, pair<int,int> > > > vec;

void update(int id,long long x){
    if(!mark[id]){
        mark[id]=1;
        dp[id]=x;
        return;
    }
    dp[id]=max(dp[id],x);
}

int main(){
//    freopen("guard.in", "r", stdin);
//    freopen("guard.out", "w", stdout);
    scanf("%d",&N);
    for(int i=1;i<=N;i++){
        int c,f,v; scanf("%d%d%d",&c,&f,&v);
        vec.push_back({-f,{0,{c,-v}}});
    }
    scanf("%d",&M);
    for(int i=1;i<=M;i++){
        int c,f,v; scanf("%d%d%d",&c,&f,&v);
        vec.push_back({-f,{1,{c,v}}});
    }
    sort(vec.begin(),vec.end());
    memset(mark,0,sizeof(mark));
    mark[0]=1;
    dp[0]=0;
    for(int i=1;i<=N+M;i++){
        int f=-vec[i-1].first;
        int c=vec[i-1].second.second.first;
        int v=vec[i-1].second.second.second;
        if(v>0){
            for(int j=0;j+c<=N*50;j++){
                if(mark[j+c]) update(j,dp[j+c]+v);
            }
        }
        else{
            for(int j=N*50;j>=c;j--){
                if(mark[j-c]) update(j,dp[j-c]+v);
            }
        }
    }
    long long ans=0;
    for(int i=1;i<=N*50;i++)if(mark[i]) ans=max(ans,dp[i]);
    printf("%lld\n",ans);

    return 0;
}


Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:40:13: warning: unused variable 'f' [-Wunused-variable]
   40 |         int f=-vec[i-1].first;
      |             ^
clo.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d",&N);
      |     ~~~~~^~~~~~~~~
clo.cpp:27:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |         int c,f,v; scanf("%d%d%d",&c,&f,&v);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
clo.cpp:30:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |     scanf("%d",&M);
      |     ~~~~~^~~~~~~~~
clo.cpp:32:25: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         int c,f,v; scanf("%d%d%d",&c,&f,&v);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~
#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...