제출 #1030702

#제출 시각아이디문제언어결과실행 시간메모리
1030702LmaoLmaoCloud Computing (CEOI18_clo)C++14
18 / 100
1 ms600 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; using ii = pair<int, int>; using aa = array<ll,3>; const int N = 1e6+5; const int INF = 1e9; aa a[10000]; ll dp[100005]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int core=0; for(int i=0;i<n;i++) { cin >> a[i][2] >> a[i][0] >> a[i][1]; a[i][1]*=-1; core+=a[i][2]; } int m; cin >> m; for(int i=n;i<m+n;i++) { cin >> a[i][2] >> a[i][0] >> a[i][1]; a[i][2]*=-1; } sort(a,a+n+m,greater<>()); for(int i=1;i<=core;i++) dp[i]=-1e15; ll ans=-1e15; for(int i=0;i<n+m;i++) { if(a[i][2]<0) { for(int j=0;j<=core;j++) { if(j-a[i][2]<=core) { dp[j]=max(dp[j],dp[j-a[i][2]]+a[i][1]); ans=max(ans,dp[j]); } } } else { for(int j=core;j>=0;j--) { if(j-a[i][2]<=core) { dp[j]=max(dp[j],dp[j-a[i][2]]+a[i][1]); ans=max(ans,dp[j]); } } } } cout << ans; return 0; }
#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...