Submission #841820

# Submission time Handle Problem Language Result Execution time Memory
841820 2023-09-02T06:57:38 Z WLZ Cloud Computing (CEOI18_clo) C++17
100 / 100
516 ms 2908 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

const ll LINF = (ll) 1e18;
const int maxc = 10003;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n; cin >> n;
  vector< tuple<int, int, int> > a;
  int sum_c = 0;
  for (int i = 0; i < n; i++) {
    int c, f, v;
    cin >> c >> f >> v;
    sum_c += c;
    a.emplace_back(f, v, c);
  }
  int m; cin >> m;
  for (int i = 0; i < m; i++) {
    int c, f, v;
    cin >> c >> f >> v;
    a.emplace_back(f, -v, c);
  }
  sort(a.rbegin(), a.rend());
  vector< vector<ll> > dp(2, vector<ll>(sum_c + 1, -LINF));
  dp[0][0] = 0;
  for (int i = 0; i < n + m; i++) {
    int cur = i % 2;
    int f, v, c;
    tie(f, v, c) = a[i];
    for (int j = 0; j <= sum_c; j++) dp[!cur][j] = dp[cur][j];
    if (v > 0) for (int j = 0; j + c <= sum_c; j++) dp[!cur][j + c] = max(dp[!cur][j + c], dp[cur][j] - v);
    else for (int j = c; j <= sum_c; j++) dp[!cur][j - c] = max(dp[!cur][j - c], dp[cur][j] - v);
  }
  cout << *max_element(dp[(n + m) % 2].begin(), dp[(n + m) % 2].end()) << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 26 ms 860 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 125 ms 1628 KB Output is correct
8 Correct 24 ms 604 KB Output is correct
9 Correct 209 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 480 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 12 ms 604 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 235 ms 1628 KB Output is correct
6 Correct 430 ms 2652 KB Output is correct
7 Correct 450 ms 2652 KB Output is correct
8 Correct 425 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 27 ms 860 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 432 ms 2652 KB Output is correct
6 Correct 437 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 2 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 26 ms 860 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 125 ms 1628 KB Output is correct
16 Correct 24 ms 604 KB Output is correct
17 Correct 209 ms 2396 KB Output is correct
18 Correct 0 ms 480 KB Output is correct
19 Correct 0 ms 600 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 12 ms 604 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 235 ms 1628 KB Output is correct
31 Correct 430 ms 2652 KB Output is correct
32 Correct 450 ms 2652 KB Output is correct
33 Correct 425 ms 2396 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 27 ms 860 KB Output is correct
37 Correct 5 ms 348 KB Output is correct
38 Correct 432 ms 2652 KB Output is correct
39 Correct 437 ms 2652 KB Output is correct
40 Correct 33 ms 860 KB Output is correct
41 Correct 79 ms 1116 KB Output is correct
42 Correct 8 ms 348 KB Output is correct
43 Correct 488 ms 2908 KB Output is correct
44 Correct 492 ms 2908 KB Output is correct
45 Correct 516 ms 2908 KB Output is correct
46 Correct 3 ms 348 KB Output is correct
47 Correct 6 ms 348 KB Output is correct
48 Correct 9 ms 348 KB Output is correct