# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
977306 | PieArmy | Cloud Computing (CEOI18_clo) | C++17 | 103 ms | 2140 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
typedef long long ll;
ll pie(ll army){return (1ll<<army);}
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define endl '\n'
#define mid ((left+right)>>1)
const ll inf=2000000000000000005;
const int sonsuz=2000000005;
using namespace std;
ll fpow(ll x,ll y,ll m=0){if(y<0){cout<<"powError";return -1;}if(m)x%=m;ll res=1;while(y>0){if(y&1)res*=x;x*=x;if(m){x%=m;res%=m;}y>>=1;}return res;}
int n,m;
void code(){
cin>>n;
int c[n],f[n],v[n],C[n],F[n],V[n];
for(int i=0;i<n;i++){
cin>>c[i]>>f[i]>>v[i];
}
cin>>m;
for(int i=0;i<m;i++){
cin>>C[i]>>F[i]>>V[i];
}
int p[n],P[m];
iota(p,p+n,0);iota(P,P+m,0);
sort(p,p+n,[&](const int &x,const int &y){return f[x]>f[y];});
sort(P,P+m,[&](const int &x,const int &y){return F[x]>F[y];});
ll dp[n+1][51];
for(int i=0;i<=n;i++){
for(int j=0;j<=50;j++){
dp[i][j]=-inf;
}
}
dp[0][0]=0;
for(int i=0;i<m;i++){
ll dp2[n+1][51];
for(int j=0;j<=n;j++){
for(int l=0;l<=50;l++){
dp2[j][l]=dp[j][l];
}
}
for(int j=0;j<n;j++){
for(int l=0;l<=50;l++){
if(dp[j][l]==-inf)continue;
dp[j+1][l]=max(dp[j+1][l],dp[j][l]);
if(l>=C[P[i]]){
dp2[j][l-C[P[i]]]=max(dp2[j][l-C[P[i]]],dp[j][l]+V[P[i]]);
}
if(f[p[j]]>=F[P[i]]){
if(l+c[p[j]]<C[P[i]]){
dp[j+1][l+c[p[j]]]=max(dp[j+1][l+c[p[j]]],dp[j][l]-v[p[j]]);
}
else if(l<C[P[i]]){
dp2[j+1][l+c[p[j]]-C[P[i]]]=max(dp2[j+1][l+c[p[j]]-C[P[i]]],dp[j][l]+V[P[i]]-v[p[j]]);
}
}
}
}
for(int j=0;j<=n;j++){
for(int l=0;l<=50;l++){
dp[j][l]=dp2[j][l];
}
}
}
ll ans=0;
for(int i=0;i<=n;i++){
for(int j=0;j<=50;j++){
ans=max(ans,dp[i][j]);
}
}
cout<<ans;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
int t=1;
if(!t)cin>>t;
while(t--){code();cout<<endl;}
return 0;
}
컴파일 시 표준 에러 (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... |