제출 #977306

#제출 시각아이디문제언어결과실행 시간메모리
977306PieArmyCloud Computing (CEOI18_clo)C++17
18 / 100
103 ms2140 KiB
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) 메시지

clo.cpp: In function 'int main()':
clo.cpp:78:32: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                         ~~~~~~~^~~~~~~~~~~~~~~~~
clo.cpp:78:57: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |  bool usaco=0;if(usaco){freopen(".in","r",stdin);freopen(".out","w",stdout);}
      |                                                  ~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...