이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define all(v) v.begin(),v.end()
#define trav(a,v) for(auto&a:v)
#define sz(a) a.size()
typedef long double ld;
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
cin.sync_with_stdio(false);
ll n,m;
cin >> n;
vector<pair<pair<ll, ll>, pair<ll, ll>>> v(n);
rep(i, 0, n) {
cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
v[i].first.first *= -1;
}
cin >> m;
v.resize(n + m);
rep(i, n, n+m) {
cin >> v[i].second.first >> v[i].first.first >> v[i].second.second;
v[i].first.first *= -1;
v[i].first.second = 1;
}
sort(all(v));
vector<ll>dp(1e5 + 5, -inf);
dp[0] = 0;
vector<ll> dp0 = dp;
ll sumc = 1;
rep(i, 0, n+m) {
rep(j, 0, sumc) {
if (!v[i].first.second) {
if (dp0[j] != -inf)if(v[i].second.first + j<dp.size())dp[v[i].second.first + j] = max(dp0[v[i].second.first + j], dp0[j]-v[i].second.second);
}
else {
if (dp0[j] != -inf)if (-v[i].second.first + j >= 0)dp[-v[i].second.first + j] = max(dp0[-v[i].second.first + j], dp0[j] + v[i].second.second);
}
}
sumc += v[i].second.first;
dp0 = dp;
}
ll ans = 0;
rep(i, 0, 1e5 + 1)ans = max(dp[i], ans);
cout<<ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:39:60: 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]
39 | if (dp0[j] != -inf)if(v[i].second.first + j<dp.size())dp[v[i].second.first + j] = max(dp0[v[i].second.first + j], dp0[j]-v[i].second.second);
# | 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... |