제출 #520932

#제출 시각아이디문제언어결과실행 시간메모리
520932Wayne_YanCloud Computing (CEOI18_clo)C++17
72 / 100
428 ms2004 KiB
#include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; #define int long long typedef int64_t ll; typedef long double ld; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define pb emplace_back #define mp make_pair #define mt make_tuple #define pii pair<int,int> #define F(n) Fi(i,n) #define Fi(i,n) Fl(i,0,n) #define Fl(i,l,n) for(int i=l;i<n;i++) #define RF(n) RFi(i,n) #define RFi(i,n) RFl(i,0,n) #define RFl(i,l,n) for(int i=n-1;i>=l;i--) #define all(v) begin(v),end(v) #define siz(v) (ll(v.size())) #define get_pos(v,x) (lower_bound(all(v),x)-begin(v)) #define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v)) #define mem(v,x) memset(v,x,sizeof v) #define ff first #define ss second #define mid ((l+r)>>1) #define RAN(a,b) uniform_int_distribution<int> (a, b)(rng) #define debug(x) (cerr << (#x) << " = " << x << "\n") #define cmax(a,b) (a = max(a,b)) #define cmin(a,b) (a = min(a,b)) template <typename T> using max_heap = __gnu_pbds::priority_queue<T,less<T> >; template <typename T> using min_heap = __gnu_pbds::priority_queue<T,greater<T> >; template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>; const int maxN = 2005; const int maxC = 50; const int INF = 8e18; int N; struct item{ int c, f, p; item(){} item(int cc, int ff, int pp) : c(cc), f(ff), p(pp) {} bool operator < (const item &rhs) const { return f > rhs.f; } } input[maxN << 1]; int dp[2][maxN * maxC]; signed main(){ int n; cin >> n; F(n){ int a,b,c; cin >> a >> b >> c; input[i] = (item){a,b,-c}; } int m; cin >> m; F(m){ int a,b,c; cin >> a >> b >> c; input[i+n] = (item){-a, b, c}; } N = n+m; sort(input, input+N); fill(dp[0], dp[0] + maxN*maxC, -INF); fill(dp[1], dp[1] + maxN*maxC, -INF); dp[0][0] = 0; bool flip = 0; int ans = -INF; F(N){ int old = flip; int curr = 1 - flip; item proc = input[i]; Fi(j, maxN*maxC){ dp[curr][j] = dp[old][j]; if( j - proc.c < 0 || j - proc.c >= maxN*maxC) continue; cmax(dp[curr][j], dp[old][j - proc.c] + proc.p); } flip = 1-flip; if(i == N-1){ Fi(j, maxN * maxC) cmax(ans, dp[curr][j]); } } printf("%lld", 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...