이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 2010 * 50;
int n, m;
long long dp[N];
struct dta {
int c, f, v, type;
int operator < (const dta& other) const {
if (f != other.f) return f > other.f;
return type > other.type;
}
};
int main() {
ios :: sync_with_stdio(0); cin.tie(0);
vector <dta> events;
cin >> n;
for (int i = 0; i < n; ++i) {
int c, f, v;
cin >> c >> f >> v;
events.push_back({c, f, v, 1});
}
cin >> m;
for (int i = 0; i < m; ++i) {
int c, f, v;
cin >> c >> f >> v;
events.push_back({c, f, v, -1});
}
sort(events.begin(), events.end());
int cur = 0;
memset(dp, - 60, sizeof(dp));
dp[0] = 0;
for (auto [c, f, v, type]: events) {
if (type == 1) {
for (int i = cur; i >= 0; --i)
dp[i + c] = max(dp[i + c], dp[i] - v);
cur += c;
} else {
for (int i = c; i <= cur; ++i)
dp[i - c] = max(dp[i - c], dp[i] + v);
}
}
cout << *max_element(dp, dp + N);
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
2 | #pragma GCC optimization ("O3")
|
clo.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
3 | #pragma GCC optimization ("unroll-loops")
|
clo.cpp: In function 'int main()':
clo.cpp:45:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
45 | for (auto [c, f, v, type]: events) {
| ^
# | 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... |