이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define sortshit second.first
#define c second.second.first
#define v second.second.second
constexpr ll inf = 1e18;
int n,m,rdz,tc,tf,tv;
vector<pair <int, pair<int,pair<int,int>>>> arr;
vector <ll> dp,temp;
ll res;
void em(int it, int af, int at, int ac, int av)
{
arr[it].f = af;
arr[it].sortshit = at;
arr[it].c = ac;
arr[it].v = av;
}
void preprocess()
{
cin.tie(0) -> ios_base::sync_with_stdio(0);
cin >> n;
arr.resize(n);
for(int i=0; i<n; i++)
{
cin >> tc >> tf >> tv;
em(i, -tf, 69, tc, -tv);
rdz += tc;
}
cin >> m;
arr.resize(n+m);
for(int i=0; i<m; i++)
{
cin >> tc >> tf >> tv;
em(i+n, -tf, 420, -tc, tv);
}
}
void solve()
{
sort(arr.begin(), arr.end());
dp.resize(rdz+69);
temp.resize(rdz+69);
for(int i=1; i<dp.size(); i++)
dp[i] = -inf;
for(auto a : arr)
{
temp = dp;
for(int j=a.c; j<=rdz; j++)
temp[j] = max(temp[j], dp[j - a.c] + a.v);
swap(dp, temp);
}
for(auto x : dp)
res = max(x,res);
cout << res;
}
int main()
{
preprocess();
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'void solve()':
clo.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i=1; i<dp.size(); i++)
| ~^~~~~~~~~~
# | 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... |