# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
951675 | Github | Cloud Computing (CEOI18_clo) | C++17 | 747 ms | 2296 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <queue>
#include <cstring>
#include <map>
#include <climits>
#include <cmath>
#include <algorithm>
#include <stack>
#include <set>
using namespace std;
#define speedup ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
#define pr printf
#define sc scanf
#define fi first
#define si second
const ll MOD = 998244353;
const ll INF = 1e17;
void setIO(string s){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
struct Event{
ll c, f, v;
};
int main() {
speedup
int n; cin >> n;
vector<Event> a;
ll mx = 0;
for (int i = 0; i < n; i++){
ll ci, f, v; cin >> ci >> f >> v;
mx += ci;
a.push_back({ci, f, -v});
}
int m; cin >> m;
for (int i = 0; i < m; i++){
ll c, f, v; cin >> c >> f >> v;
a.push_back({-c, f, v});
}
auto cmp = [&](Event x, Event y){
return (x.f == y.f ? x.v < y.v: x.f > y.f);
};
sort(a.begin(), a.end(), cmp);
vector<ll> oldDP(mx+1, LLONG_MIN);
oldDP[0] = 0;
for (Event& x: a){
vector<ll> newDP(oldDP);
for (ll c = 0; c <= mx; c++){
ll p = c - x.c;
if (0 <= p && p <= mx && oldDP[p] != LLONG_MIN){
newDP[c] = max(newDP[c], oldDP[p]+x.v);
}
}
oldDP = newDP;
}
cout << *max_element(oldDP.begin(), oldDP.end()) << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |