답안 #601739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
601739 2022-07-22T09:29:21 Z pakhomovee Cloud Computing (CEOI18_clo) C++17
100 / 100
538 ms 1440 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

#define int long long
const int inf = 1e18;
const int maxn = 100'001;
int dp[maxn];

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    vector<pair<pair<int, int>, pair<int, int>>> vv;
    for (int i = 0; i < n; ++i) {
        int c, f, v;
        cin >> c >> f >> v;
        vv.push_back({ { f, -1 }, { v, c } });
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int c, f, v;
        cin >> c >> f >> v;
        vv.push_back({ { f, -2 }, { v, c } });
    }
    sort(vv.rbegin(), vv.rend());
    fill(dp, dp + maxn, -inf);
    dp[0] = 0;
    for (pair<pair<int, int>, pair<int, int>> x : vv) {
        auto [p, q] = x;
        auto [f, t] = p;
        auto [v, c] = q;
        if (t == -1) {
            for (int j = maxn - 1; j >= c; --j) {
                dp[j] = max(dp[j - c] - v, dp[j]);
            }
        } else {
            for (int j = 0; j + c < maxn; ++j) {
                dp[j] = max(dp[j], dp[j + c] + v);
            }
        }
    }
    cout << *max_element(dp, dp + maxn);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 2 ms 1092 KB Output is correct
3 Correct 13 ms 1108 KB Output is correct
4 Correct 23 ms 1108 KB Output is correct
5 Correct 212 ms 1252 KB Output is correct
6 Correct 197 ms 1260 KB Output is correct
7 Correct 213 ms 1264 KB Output is correct
8 Correct 218 ms 1256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 2 ms 980 KB Output is correct
3 Correct 19 ms 1112 KB Output is correct
4 Correct 13 ms 1116 KB Output is correct
5 Correct 92 ms 1164 KB Output is correct
6 Correct 130 ms 1168 KB Output is correct
7 Correct 284 ms 1268 KB Output is correct
8 Correct 281 ms 1260 KB Output is correct
9 Correct 230 ms 1236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1108 KB Output is correct
2 Correct 6 ms 1052 KB Output is correct
3 Correct 23 ms 1112 KB Output is correct
4 Correct 23 ms 1108 KB Output is correct
5 Correct 39 ms 1160 KB Output is correct
6 Correct 56 ms 1108 KB Output is correct
7 Correct 65 ms 1128 KB Output is correct
8 Correct 73 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 980 KB Output is correct
2 Correct 4 ms 1108 KB Output is correct
3 Correct 189 ms 1212 KB Output is correct
4 Correct 174 ms 1236 KB Output is correct
5 Correct 419 ms 1396 KB Output is correct
6 Correct 455 ms 1388 KB Output is correct
7 Correct 523 ms 1396 KB Output is correct
8 Correct 456 ms 1388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1128 KB Output is correct
2 Correct 27 ms 1128 KB Output is correct
3 Correct 114 ms 1148 KB Output is correct
4 Correct 194 ms 1236 KB Output is correct
5 Correct 458 ms 1400 KB Output is correct
6 Correct 414 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 980 KB Output is correct
2 Correct 2 ms 1092 KB Output is correct
3 Correct 13 ms 1108 KB Output is correct
4 Correct 23 ms 1108 KB Output is correct
5 Correct 212 ms 1252 KB Output is correct
6 Correct 197 ms 1260 KB Output is correct
7 Correct 213 ms 1264 KB Output is correct
8 Correct 218 ms 1256 KB Output is correct
9 Correct 2 ms 980 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 19 ms 1112 KB Output is correct
12 Correct 13 ms 1116 KB Output is correct
13 Correct 92 ms 1164 KB Output is correct
14 Correct 130 ms 1168 KB Output is correct
15 Correct 284 ms 1268 KB Output is correct
16 Correct 281 ms 1260 KB Output is correct
17 Correct 230 ms 1236 KB Output is correct
18 Correct 4 ms 1108 KB Output is correct
19 Correct 6 ms 1052 KB Output is correct
20 Correct 23 ms 1112 KB Output is correct
21 Correct 23 ms 1108 KB Output is correct
22 Correct 39 ms 1160 KB Output is correct
23 Correct 56 ms 1108 KB Output is correct
24 Correct 65 ms 1128 KB Output is correct
25 Correct 73 ms 1152 KB Output is correct
26 Correct 4 ms 980 KB Output is correct
27 Correct 4 ms 1108 KB Output is correct
28 Correct 189 ms 1212 KB Output is correct
29 Correct 174 ms 1236 KB Output is correct
30 Correct 419 ms 1396 KB Output is correct
31 Correct 455 ms 1388 KB Output is correct
32 Correct 523 ms 1396 KB Output is correct
33 Correct 456 ms 1388 KB Output is correct
34 Correct 2 ms 1128 KB Output is correct
35 Correct 27 ms 1128 KB Output is correct
36 Correct 114 ms 1148 KB Output is correct
37 Correct 194 ms 1236 KB Output is correct
38 Correct 458 ms 1400 KB Output is correct
39 Correct 414 ms 1368 KB Output is correct
40 Correct 100 ms 1168 KB Output is correct
41 Correct 201 ms 1240 KB Output is correct
42 Correct 340 ms 1368 KB Output is correct
43 Correct 538 ms 1368 KB Output is correct
44 Correct 476 ms 1408 KB Output is correct
45 Correct 494 ms 1440 KB Output is correct
46 Correct 216 ms 1264 KB Output is correct
47 Correct 348 ms 1364 KB Output is correct
48 Correct 310 ms 1356 KB Output is correct