이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fr first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pw(x) (1ll << x)
#define pb push_back
#define endl '\n'
#define sz(x) (int)((x).size())
#define vec vector
using namespace std;
template <typename T> inline bool umin (T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool umax (T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
inline void solve () {
int n; cin >> n;
vector <array <ll, 4>> ful;
vector <ll> c (n), f (n), v (n);
for (int i = 0; i < n; ++i) {
cin >> c[i] >> f[i] >> v[i];
ful.pb({f[i], 1, v[i], c[i]});
}
int m; cin >> m;
vector <ll> qc (m), qf (m), qv (m);
for (int i = 0; i < m; ++i) {
cin >> qc[i] >> qf[i] >> qv[i];
ful.pb({qf[i], 0, qv[i], qc[i]});
}
const int MX = 50 * n + 51;
vector <ll> dp (MX, -1e18);
dp[0] = 0;
sort(all(ful));
while (sz(ful)) {
auto [f, type, v, c] = ful.back();
if (type == 1) {
for (int i = MX - 1 - c; i >= 0; --i) {
dp[i + c] = max(dp[i + c], dp[i] - v);
}
}
else {
for (int i = c; i < MX; ++i) {
dp[i - c] = max(dp[i - c], dp[i] + v);
}
}
ful.pop_back();
}
cout << *max_element(all(dp));
}
signed main () {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int t = 1; // cin >> t;
while (t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'void solve()':
clo.cpp:40:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
40 | auto [f, type, v, c] = ful.back();
| ^
# | 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... |