이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define piii pair<int,pair<int,int>>
#define fi first
#define se second
const int N = 2e3 + 5;
const int inf = 0x3f3f3f3f3f3f3f3f;
vector<piii>vec;
vector<int>dp_before,dp_cur;
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
int c,f,v;
cin >> c >> f >> v;
vec.push_back({f,{c,-v}});
}
int m;
cin >> m;
for (int i = 1; i <= m; i++) {
int c,f,v;
cin >> c >> f >> v;
vec.push_back({f,{-c,v}});
}
sort(vec.rbegin(),vec.rend());
dp_before.push_back(0);
for (int i = 0; i < (int)vec.size(); i++) {
dp_cur = dp_before;
for (int j = 0; j < dp_before.size(); j++) {
int newCnt = j + vec[i].se.fi,newCost = dp_before[j] + vec[i].se.se;
if (newCnt >= 0) {
while ((int)dp_cur.size() <= newCnt) dp_cur.push_back(-inf);
dp_cur[newCnt] = max(dp_cur[newCnt],newCost);
}
}
dp_before = dp_cur;
}
int ans = 0;
for (auto x: dp_before) ans = max(ans,x);
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:35:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for (int j = 0; j < dp_before.size(); j++) {
| ~~^~~~~~~~~~~~~~~~~~
# | 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... |