Submission #1050256

#TimeUsernameProblemLanguageResultExecution timeMemory
1050256antonCloud Computing (CEOI18_clo)C++17
18 / 100
1 ms1372 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> int N, M; vector<pii> computers; vector<pii> orders; void chm(int& i, int v){ i = max(i, v); } signed main(){ cin>>N; for(int i = 0; i<N; i++){ int c, f, v; cin>>c>>f>>v; computers.push_back({f, v}); } cin>>M; for(int i = 0; i<M; i++){ int c, f, v; cin>>c>>f>>v; orders.push_back({f, v}); } sort(computers.begin(), computers.end()); sort(orders.begin(), orders.end()); reverse(computers.begin(), computers.end()); reverse(orders.begin(), orders.end()); vector<vector<int>> dp(N+1, vector<int>(M+1, 0)); for(int cur_comp = 0; cur_comp<=N; cur_comp++){ for(int cur_order = 0; cur_order<=M; cur_order++){ int cur_v= dp[cur_comp][cur_order]; if(cur_comp<N){ chm(dp[cur_comp+1][cur_order], cur_v); } if(cur_order<M){ chm(dp[cur_comp][cur_order+1], cur_v); } if(cur_comp<N && cur_order<M){ if(computers[cur_comp].first>=orders[cur_order].first){ chm(dp[cur_comp+1][cur_order+1], cur_v + orders[cur_order].second - computers[cur_comp].second); } } } } cout<<dp[N][M]<<endl; }
#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...