제출 #864851

#제출 시각아이디문제언어결과실행 시간메모리
864851dead0neCloud Computing (CEOI18_clo)C++17
36 / 100
206 ms262144 KiB
#pragma GCC optimize("unroll-loops,Ofast,O3") #include <bits/stdc++.h> #define pb push_back #define mp make_pair #define spc << " " << #define endl "\n" #define all(x) x.begin(), x.end() #define int long long #define ii pair<int,int> #define vi vector<int> #define vii vector<ii> #define st first #define nd second #define inf 1000000009 #define MOD 1000000007 #define lim 200005 using namespace std; int n,m; vector<tuple<int, int, int>> vec; // frequence, core, value int dp[4001][10001]; int calc(int cur, int cor){ if(cur>=n+m) return 0; if(dp[cur][cor]!=-1) return dp[cur][cor]; if(cor >= (n+m-cur)*50){ if(get<1>(vec[cur]) > 0){ return dp[cur][cor] = calc(cur+1, cor); } else{ return dp[cur][cor] = calc(cur+1, cor + get<1>(vec[cur])) + get<2>(vec[cur]); } } dp[cur][cor] = calc(cur+1, cor); if(cor + get<1>(vec[cur]) >= 0) dp[cur][cor] = max(dp[cur][cor], calc(cur+1, cor + get<1>(vec[cur])) + get<2>(vec[cur])); return dp[cur][cor]; } void solve(){ cin >> n; for(int i=1; i<=n; i++){ int c,f,v; cin >> c >> f >> v; vec.pb({f, c, -v}); } cin >> m; for(int i=1; i<=m; i++){ int c,f,v; cin >> c >> f >> v; vec.pb({f, -c, v}); } for(int i=0; i<=n+m; i++) for(int j=0; j<=min(10000ll, (n+m)*50); j++) dp[i][j]=-1; sort(all(vec), greater<tuple<int, int, int>>()); //for(auto i:vec) cerr << get<0>(i) spc get<1>(i) spc get<2>(i) << endl; cout << max(calc(0, 0), 0ll) << endl; } signed main(){ ios_base::sync_with_stdio(false);cin.tie(0); #ifdef Local freopen("in","r",stdin); freopen("out","w",stdout); #endif int t=1; //cin >> t; while(t--) solve(); }
#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...