제출 #1305581

#제출 시각아이디문제언어결과실행 시간메모리
1305581liangjeremyCloud Computing (CEOI18_clo)C++20
18 / 100
291 ms2080 KiB
#include<bits/stdc++.h> #include<bits/extc++.h> #define fi first #define se second #define int long long using namespace std; //using namespace __gnu_pbds; using db=double; using ll=int64_t; using sll=__int128; using lb=long double; mt19937 rng(random_device{}()); int32_t main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int>c1(n+1); vector<int>p1(n+1); for(int i=1; i<=n; i++){ int x; cin>>c1[i]>>x>>p1[i]; } int m; cin>>m; vector<int>c2(m+1); vector<int>p2(m+1); for(int i=1; i<=m; i++){ int x; cin>>c2[i]>>x>>p2[i]; } const int maxn=1e5+10; vector<int>dp1(maxn+1,1e18); vector<int>dp2(maxn+1,-1e18); dp1[0]=0; dp2[0]=0; for(int i=1; i<=n; i++){ for(int j=maxn; j>=c1[i]; j--){ dp1[j]=min(dp1[j],dp1[j-c1[i]]+p1[i]); } } for(int i=1; i<=m; i++){ for(int j=maxn; j>=c2[i]; j--){ dp2[j]=max(dp2[j],dp2[j-c2[i]]+p2[i]); } } int ans=0; int mx=0; for(int i=0; i<=maxn; i++){ mx=max(mx,dp2[i]); ans=max(ans,mx-dp1[i]); } cout<<ans<<'\n'; } /* Overhead the albatross hangs motionless upon the air And deep beneath the rolling waves in labyrinths of coral caves The echo of a distant time comes willowing across the sand And everything is green and submarine And no one showed us to the land And no one knows the wheres or whys But something stirs and something tries And starts to climb towards the light */
#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...