제출 #1084580

#제출 시각아이디문제언어결과실행 시간메모리
1084580whtthCloud Computing (CEOI18_clo)C++14
100 / 100
254 ms1372 KiB
#include<bits/stdc++.h> using namespace std; const long long infneg = -1e18; int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); vector<pair<long long, pair<long long,long long>>> ve; long long n; cin>>n; for(int i=1;i<=n;i++){ long long a, b, c; cin>>a>>b>>c; ve.push_back({b,{a,-c}}); } cin>>n; for(int i=1;i<=n;i++){ long long a, b, c; cin>>a>>b>>c; ve.push_back({b,{-a,c}}); } sort(ve.begin(), ve.end()); vector<long long> dp(1e5+1,infneg); dp[0]=0; for(int j=ve.size()-1;j>=0;j--){ long long k=ve[j].second.first, p=ve[j].second.second; if(k>0) for(int i=1e5-k;i>=0;i--)dp[k+i]=max(dp[k+i],dp[i]+p); else for(int i=-k;i<=1e5;i++)dp[k+i]=max(dp[k+i],dp[i]+p); } long long ans = 0; for (int i=0;i<=1e5;i++)ans=max(ans, dp[i]); 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...