Submission #853478

#TimeUsernameProblemLanguageResultExecution timeMemory
853478MarwenElarbiCloud Computing (CEOI18_clo)C++17
54 / 100
12 ms23316 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define vi vector<int> #define ve vector #define ll long long #define vl vector<ll> #define vll vector<pair<ll,ll>> #define onbit __builtin_popcount #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define mp make_pair #define fi first #define se second #define INF 1e18 #define eps 1e-7 #define eps1 1e-2 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define MAX_A 1e5+5 using namespace std; using namespace __gnu_pbds; template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; const ll MOD = 1e9+7; const int nax = 4e3+5; const int MAX_VAL = 1e6+1; double PI=3.14159265359; int arx[8]={1,1,0,-1,-1,-1, 0, 1}; int ary[8]={0,1,1, 1, 0,-1,-1,-1}; void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); //freopen((s + ".out").c_str(), "w", stdout); } ll dp[nax][751]; int main(){ optimise; /*#ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif*/ //setIO("Dull"); int n; cin>>n; vector<pair<ll,ii>> tab(4000); for (int i = 0; i < n; ++i) { cin>>tab[i].se.se>>tab[i].fi>>tab[i].se.fi; } int m; cin>>m; //return 0; for (int i = 0; i < n+m; ++i) { for (int j = 0; j < 751; ++j) { dp[i][j]=-1e18; } } for (int i = 0; i < m; ++i) { cin>>tab[i+n].se.se>>tab[i+n].fi>>tab[i+n].se.fi; tab[i+n].se.fi=-tab[i+n].se.fi; } tab.resize(n+m); sort(tab.begin(),tab.end(),greater<>()); for (int i = 0; i < n+m; ++i) { tab[i].se.fi=-tab[i].se.fi; //cout<<tab[i].fi<<" "<<tab[i].se.fi<<" "<<tab[i].se.se<<endl; } dp[0][0]=0; if (tab[0].se.fi<0) dp[0][tab[0].se.se]=tab[0].se.fi; ll mx=0; for (int i = 0; i < n+m; ++i) { for (int j = 0; j < 751; ++j) { if(i<n+m-1){ if (dp[i][j]!=-1e18){ if (tab[i+1].se.fi<0){ dp[i+1][j+tab[i+1].se.se]=max(dp[i+1][j+tab[i+1].se.se],dp[i][j]+tab[i+1].se.fi); dp[i+1][j]=max(dp[i+1][j],dp[i][j]); }else{ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if (tab[i+1].se.se>j) continue; dp[i+1][j-tab[i+1].se.se]=max(dp[i+1][j-tab[i+1].se.se],dp[i][j]+tab[i+1].se.fi); } } } //if(dp[i][j] != -1e18) cout <<i<<" "<<j<<" "<<dp[i][j]<<endl; mx=max(mx,dp[i][j]); } }cout <<mx<<endl; }

Compilation message (stderr)

clo.cpp: In function 'void setIO(std::string)':
clo.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...