이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<array<ll, 3>> pts;
int s = 0;
for (int i=0; i<n; i++) {
ll c, v, f; cin >> c >> f >> v;
pts.push_back({f, c, -v});
s += c;
}
int m; cin >> m;
for (int i=0; i<m; i++) {
ll c, v, f; cin >> c >> f >> v;
pts.push_back({f, c, v});
}
sort(pts.rbegin(), pts.rend());
vector<ll> dp(s+1, -1e18);
dp[0] = 0;
for (auto [f, c, v] : pts) {
// cout << f << ' ' << c << ' ' << v << endl;
if (v > 0) { // cust
for (int i=c; i<=s; i++) {
dp[i - c] = max(dp[i - c], dp[i] + v);
}
} else { // comp
for (int i=s-c; i>=0; i--) {
dp[i + c] = max(dp[i + c], dp[i] + v);
}
}
}
ll ans = 0;
for (ll x : dp) ans = max(ans, x);
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:29:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
29 | for (auto [f, c, v] : pts) {
| ^
# | 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... |