제출 #434308

#제출 시각아이디문제언어결과실행 시간메모리
434308xiaowuc1Cloud Computing (CEOI18_clo)C++17
100 / 100
659 ms1228 KiB
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cstring> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <random> #include <set> #include <stack> #include <vector> using namespace std; // BEGIN NO SAD #define rep(i, a, b) for(int i = a; i < (b); ++i) #define trav(a, x) for(auto& a : x) #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define mp make_pair #define pb push_back #define eb emplace_back #define lb lower_bound #define ub upper_bound typedef vector<int> vi; #define f first #define s second // END NO SAD typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<vector<ll>> matrix; void init(vector<array<int, 3>>& v) { int n; cin >> n; v.resize(n); for(auto& x: v) cin >> x[1] >> x[0] >> x[2]; sort(all(v)); } const ll BAD = -1e18; ll dp[100005]; void solve() { vector<array<int, 3>> computers; // <clock rate, cores, price> vector<array<int, 3>> jobs; // <clock rate, cores, price> init(computers); init(jobs); fill(dp, dp + 100005, BAD); dp[0] = 0; ll ret = 0; while(sz(jobs)) { if(sz(computers) && computers.back()[0] >= jobs.back()[0]) { auto x = computers.back(); computers.pop_back(); for(int i = 100000; i >= x[1]; i--) { if(dp[i-x[1]] == BAD) continue; dp[i] = max(dp[i], dp[i-x[1]] - x[2]); } } else { auto x = jobs.back(); jobs.pop_back(); for(int i = 0; i + x[1] <= 100000; i++) { if(dp[i+x[1]] == BAD) continue; ret = max(ret, dp[i] = max(dp[i], dp[i+x[1]] + x[2])); } } } cout << ret << "\n"; } // what would chika do // are there edge cases (N=1?) // are array sizes proper (scaled by proper constant, for example 2* for koosaga tree) // integer overflow? // DS reset properly between test cases // are you doing geometry in floating points int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 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...