Submission #1006382

#TimeUsernameProblemLanguageResultExecution timeMemory
1006382makanhuliaCloud Computing (CEOI18_clo)C++17
0 / 100
7 ms1368 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<ll,ll> #define REP(i,x,y) for(ll i=x;i<=y;i++) #define freeopen freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #define mod 1000000000 #define pb push_back #define mk make_pair #define ll long long #define foor(x,vec) for(auto x:vec ){cout<<x<<" ";} #define fi first #define se second #define MAXN 500069 #define lld long double #define cha ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define ffl fflush(stdout) #define sst string #define pii pair<ll,ll> ll mvx[]={0,0,-1,1}; ll mvy[]={1,-1,0,0}; ll n,m,c[2009],C[2009],F[2009],f[2009],v[2009],V[2009]; ll dp[200069]; void solve(){ cin>>n; vector <pair<pii,pii>> vec; REP(i,1,n){ cin>>c[i]>>f[i]>>v[i]; vec.pb({{f[i],1},{c[i],v[i]}}); } cin>>m; REP(i,1,m){ cin>>C[i]>>F[i]>>V[i]; vec.pb({{F[i],0},{C[i],V[i]}}); } REP(i,1,100000)dp[i]=-1e18; sort(vec.begin(),vec.end(),greater<pair<pii,pii>>()); for(auto x : vec){ if(x.fi.se){ for(ll i=100000;i>=0;i--) dp[i]=max(dp[i],dp[i-x.se.fi]-x.se.se); } else{ for(ll i=0;i<=100000;i++) dp[i]=max(dp[i],dp[i+x.se.fi]+x.se.se); } } ll ans=0; REP(i,1,10000)ans=max(ans,dp[i]); cout<<ans<<endl; } int main(){ ll tc; tc=1; // cin>>tc; while(tc--){ solve(); } }
#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...