이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  int n; cin >> n;
  vector<long long> dp((n + 1) * 50 + 1, -1e18);
  vector<array<int, 4>> events;
  while (n--) {
    int a, b, c; cin >> a >> b >> c;
    events.push_back({b, 0, a, c});
  }
  int m; cin >> m;
  while (m--) {
    int a, b, c; cin >> a >> b >> c;
    events.push_back({b, 1, a, c});
  }
  sort(events.rbegin(), events.rend());
  dp[0] = 0;
  for (auto [b, t, a, c] : events) {
    if (t == 1) {
      for (int i = 0; i < dp.size() - a; ++i) {
        dp[i] = max(dp[i], dp[i + a] + c);
      }
    } else {
      for (int i = dp.size() - 1; i >= a; --i) {
        dp[i] = max(dp[i], dp[i - a] - c);
      }
    }
  }
  cout << *max_element(dp.begin(), dp.end());
  return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:30:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |       for (int i = 0; i < dp.size() - a; ++i) {
      |                       ~~^~~~~~~~~~~~~~~| # | 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... |