이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct wow
{
int nr,rata,cost;
}v[2005],b[2005];
int n,m,i;
bool compare (pair <int,pair <int,int> > a, pair <int,pair <int,int> > b)
{
return a>b;
}
vector <pair <int,pair <int,int> > > ev;
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(0);
#ifdef HOME
ifstream cin("date.in");
ofstream cout("date.out");
#endif // HOME
cin>>n;
for (i=1;i<=n;i++)
{
cin>>v[i].nr>>v[i].rata>>v[i].cost;
v[i].cost=v[i].cost*(-1);
ev.push_back({v[i].rata,{v[i].nr,v[i].cost}});
}
cin>>m;
for (i=1;i<=m;i++)
{
cin>>b[i].nr>>b[i].rata>>b[i].cost;
ev.push_back({b[i].rata,{b[i].nr*(-1),b[i].cost}});
}
sort (ev.begin(),ev.end(),compare);
vector <long long> din{0};
for (i=0;i<ev.size();i++)
{
vector <long long> din2=din;
for (int j=0;j<din.size();j++)
{
int k=j+ev[i].second.first;
if (k>=0)
{
while ((int)din2.size()<=k)
{
din2.push_back(LLONG_MIN/2);
}
din2[k]=max(din2[k],din[j]+ev[i].second.second);
}
}
din=din2;
}
long long maxim=0;
for (int i=0;i<din.size();i++)
{
maxim=max(maxim,din[i]);
}
cout<<maxim;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:37:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for (i=0;i<ev.size();i++)
| ~^~~~~~~~~~
clo.cpp:40:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for (int j=0;j<din.size();j++)
| ~^~~~~~~~~~~
clo.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for (int i=0;i<din.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... |