제출 #968810

#제출 시각아이디문제언어결과실행 시간메모리
968810dostsCloud Computing (CEOI18_clo)C++17
72 / 100
906 ms3920 KiB
//Dost SEFEROĞLU #pragma GCC optimize("O3,unroll-loops,Ofast") #include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define ff first #define ss second #define sp << " " << #define vi vector<int> const int N = 2e7+1,inf = 2e18,MOD = 1e9+7; struct Order{ int core,power,price; }; void solve() { int n; cin >> n; vector<Order> orders; for (int i=1;i<=n;i++) { int c,f,p; cin >> c >> f >> p; orders.push_back({c,f,-p}); } int m; cin >> m; for (int i=1;i<=m;i++) { int c,f,p; cin >> c >> f >> p; orders.push_back({-c,f,p}); } sort(orders.begin(),orders.end(),[&](Order o1,Order o2) { return o1.power > o2.power; }); n = n+m; int dp[200001],dp2[200001]; for (int i=0;i<=200000;i++) dp[i] = dp2[i] = -inf; dp2[0] = 0; for (int i=0;i<n;i++) { for (int j=0;j<=200000;j++) dp[j] = -inf; for (int c = 0;c<=200000;c++) { if (dp2[c] == -inf) continue; dp[c] = max(dp[c],dp2[c]); if (c+orders[i].core >= 0 && c+orders[i].core <= 200000) { dp[c+orders[i].core] = max(dp[c+orders[i].core],dp2[c]+orders[i].price); } } for (int j=0;j<=200000;j++) dp2[j] = dp[j]; } cout << *max_element(dp2,dp2+200001) << '\n'; } signed main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Dodi freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif int t = 1; //cin >> t; while (t --> 0) 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...