제출 #397123

#제출 시각아이디문제언어결과실행 시간메모리
397123ollelCloud Computing (CEOI18_clo)C++17
18 / 100
433 ms4400 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i = a; i < b; i++) #define pb push_back #define INF 1e18 typedef vector<int> vi; typedef long long ll; struct comp { int cost, cores, speed; comp(int cst, int crs, int s) {cost = cst; cores = crs; speed = s;} comp() {}; }; int n, m; int MAXCORES = 50 * 2000 + 100; int main() { cin >> n; vector<comp> store(n); rep(i,0,n) cin >> store[i].cores >> store[i].speed >> store[i].cost; cin >> m; vector<comp> customer(m); rep(i,0,m) cin >> customer[i].cores >> customer[i].speed >> customer[i].cost; sort(store.begin(), store.end(), [](comp a, comp b) { return ((float)a.cores / (float)a.cost > (float)b.cores / (float)b.cost); }); vector<vector<ll>> kns(2, vector<ll>(MAXCORES, INF)); kns[0][store[0].cores] = store[0].cost; kns[0][0] = 0; rep(i,1,n) { rep(c, 0, store[i].cores) { kns[i&1][c] = kns[(i&1)^1][c]; } rep(c, store[i].cores, MAXCORES) { kns[i&1][c] = min(kns[(i&1)^1][c], kns[(i&1)^1][c - store[i].cores] + store[i].cost); } } sort(customer.begin(), customer.end(), [](comp b, comp a) { return ((float)a.cores / (float)a.cost > (float)b.cores / (float)b.cost); }); vector<vector<ll>> knc(2, vector<ll>(MAXCORES, -INF)); knc[0][customer[0].cores] = customer[0].cost; knc[0][0] = 0; rep(i,1,m) { rep(c, 0, customer[i].cores) { knc[i&1][c] = knc[(i&1)^1][c]; } rep(c, customer[i].cores, MAXCORES) { knc[i&1][c] = max(knc[(i&1)^1][c], knc[(i&1)^1][c - customer[i].cores] + customer[i].cost); } } for (int i = MAXCORES - 2; i; i--) kns[(n&1)^1][i] = min(kns[(n&1)^1][i], kns[(n&1)^1][i + 1]); ll ans = 0; rep(i, 0, MAXCORES) { ans = max(ans, knc[(m&1)^1][i] - kns[(n&1)^1][i]); } cout << ans; }
#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...