| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1336899 | ghassanhasan | Cloud Computing (CEOI18_clo) | C++20 | 1181 ms | 5324 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(v) v.begin(), v.end()
bool cmp(array<int, 3> &a, array<int, 3> &b){
return a[1] > b[1];
}
void doing() {
int n; cin >> n;
vector<array<int, 3>> a;
for(int i = 0; i < n; i++){
int c, f, v; cin >> c >> f >> v;
v = -v;
a.push_back({c, f, v});
}
int m; cin >> m;
for(int i = 0; i < m; i++){
int c, f, v; cin >> c >> f >> v;
c = -c;
a.push_back({c, f, v});
}
sort(all(a), cmp);
int sz = n + m, mx = 2 * n * 50 + 5;
vector dp(2, vector(mx, -(ll)1e15));
dp[0][0] = 0;
for(int i = 0; i < sz; i++){
dp[1 - (i & 1)] = vector(mx, -(ll)1e15);
for(int j = 0; j < mx; j++){
dp[1 - (i & 1)][j] = max(dp[1 - (i & 1)][j], dp[i & 1][j]);
if(j + a[i][0] >= 0 && j + a[i][0] < mx){
dp[1 - (i & 1)][j + a[i][0]] = max(dp[1 - (i & 1)][j + a[i][0]], dp[i & 1][j] + a[i][2]);
}
}
}
cout << *max_element(all(dp[(sz & 1)])) << '\n';
}
signed main() {
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
{
#ifdef GH
freopen("IN.txt", "r", stdin);
cout << string(60, '*') << endl;
#else
if (const string file = ""; !file.empty()) {
freopen((file + ".in").c_str(), "r", stdin);
freopen((file + ".out").c_str(), "w", stdout);
}
#endif
}
int tc = 1;
// cin >> tc;
while (tc--)
doing();
return 0;
}컴파일 시 표준 에러 (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... | ||||
