# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
827560 | gagik_2007 | Cloud Computing (CEOI18_clo) | C++17 | 590 ms | 2132 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define ff first
#define ss second
ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=2007;
ll n,m,k;
struct Point{
bool is_order;
int f,c,v;
Point(int fff, int cc, int vv, bool b):f(fff),c(cc),v(vv),is_order(b){}
bool operator<(const Point& other)const{
if(f==other.f){
return is_order>other.is_order;
}
return f<other.f;
}
};
vector<Point>a;
ll dp[2][N*51];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
cin>>n;
for(int i=0;i<n;i++){
int c,f,v;
cin>>c>>f>>v;
a.push_back(Point(f,c,-v,false));
}
cin>>m;
for(int i=0;i<m;i++){
int c,f,v;
cin>>c>>f>>v;
a.push_back(Point(f,-c,v,true));
}
sort(a.begin(),a.end());
reverse(a.begin(),a.end());
// for(int i=0;i<a.size();i++){
// cout<<i<<": "<<a[i].f<<" "<<a[i].c<<" "<<a[i].v<<endl;
// }
fill(dp[0],dp[0]+N*51-1,-INF);
dp[0][0]=0;
for(int i=0;i<a.size();i++){
for(int j=0;j<n*51;j++){
dp[1][j]=dp[0][j];
if(j-a[i].c>=0){
dp[1][j]=max(dp[1][j],dp[0][j-a[i].c]+a[i].v);
}
}
for(int j=0;j<n*51;j++){
dp[0][j]=dp[1][j];
// cout<<dp[0][j]<<" ";
}
// cout<<endl;
}
ll res=0;
for(int j=0;j<n*51;j++){
res=max(res,dp[0][j]);
}
cout<<res<<endl;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |