이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define sz(x) int(x.size())
#define all(x) x.begin(),x.end()
#define reset(x) memset(x, 0,sizeof(x))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define N 2005
#define remain(x) if (x > MOD) x -= MOD
#define ii pair<int, int>
#define iii pair<int, ii>
#define iiii pair< ii , ii >
#define viiii vector< iiii >
#define vi vector<int>
#define vii vector< ii >
#define bit(x, i) (((x) >> (i)) & 1)
#define Task "test"
#define int long long
using namespace std;
typedef long double ld;
const int inf = 1e12;
const int minf = -1e10;
int n, m;
vector<iii> a;
void readfile()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if (fopen(Task".inp","r"))
{
freopen(Task".inp","r",stdin);
//freopen(Task".out","w",stdout);
}
cin >> n;
for(int i=1; i<=n; i++){
int cnt, fre, cost;
cin >> cnt >> fre >> cost;
cost*=-1;
a.pb(iii(fre,ii(cnt,cost)));
}
cin >> m;
for(int i=1; i<=m; i++){
int cnt, fre, cost;
cin >> cnt >> fre >> cost;
cnt*=-1;
a.pb({fre,{cnt,cost}});
}
}
void proc()
{
sort(a.rbegin(),a.rend());
vector<int> dp{0};
for(int i=0; i<a.size(); i++){
vector<int> dp2 = dp;
for(int j=0; j<dp.size(); j++){
int cnt = j + a[i].se.fi;
int cost = dp[j] + a[i].se.se;
if (cnt >= 0){
while (dp2.size() <= cnt) dp2.pb(minf*2000);
dp2[cnt] = max(dp2[cnt],cost);
}
}
dp = dp2;
}
int ans = 0;
for(int i=0; i<dp.size(); i++) ans = max(ans,dp[i]);
cout << ans;
}
signed main()
{
readfile();
proc();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'void proc()':
clo.cpp:59:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for(int i=0; i<a.size(); i++){
| ~^~~~~~~~~
clo.cpp:61:23: 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]
61 | for(int j=0; j<dp.size(); j++){
| ~^~~~~~~~~~
clo.cpp:65:35: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
65 | while (dp2.size() <= cnt) dp2.pb(minf*2000);
| ~~~~~~~~~~~^~~~~~
clo.cpp:72:19: 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]
72 | for(int i=0; i<dp.size(); i++) ans = max(ans,dp[i]);
| ~^~~~~~~~~~
clo.cpp: In function 'void readfile()':
clo.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | freopen(Task".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# | 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... |