제출 #1305590

#제출 시각아이디문제언어결과실행 시간메모리
1305590liangjeremyCloud Computing (CEOI18_clo)C++20
18 / 100
306 ms1196 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>dp(maxn+1,-1e18); dp[0]=0; for(int i=1; i<=n; i++){ for(int j=maxn; j>=c1[i]; j--){ dp[j]=max(dp[j],dp[j-c1[i]]-p1[i]); } } for(int i=1; i<=m; i++){ for(int j=0; j+c2[i]<=maxn; j++){ dp[j]=max(dp[j],dp[j+c2[i]]+p2[i]); } } cout<<*max_element(dp.begin(),dp.end()); } /* 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...