Submission #1091570

#TimeUsernameProblemLanguageResultExecution timeMemory
1091570LmaoLmaoCloud Computing (CEOI18_clo)C++14
0 / 100
255 ms203188 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long using namespace std; using ii=pair<int,int>; using aa=array<ll,3>; ll dp[100005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); int n; cin >> n; vector<aa> a; int sum=0; for(int i=1;i<=n;i++) { aa x; cin >> x[1] >> x[0] >> x[2]; sum+=x[1]; x[2]=-x[2]; a.push_back(x); } int m; cin >> m; for(int i=1;i<=m;i++) { aa x; cin >> x[1] >> x[0] >> x[2]; x[1]=-x[1]; a.push_back(x); } for(int i=0;i<=sum;i++) dp[i]=-1e18; dp[0]=0; sort(a.begin(),a.end(),greater<>()); ll ans=0; for(aa x:a) { if(x[1]<0) { for(int i=0;i<=sum;i++) { if(i+x[1]>=0 && i+x[1]<=sum) { dp[i+x[1]]=max(dp[i+x[1]],dp[i]+x[2]); ans=max(ans,dp[i+x[1]]); } } } else { for(int i=sum;i>=0;i--) { if(i+x[1]>=0 && i+x[1]<=sum) { dp[i+x[1]]=max(dp[i+x[1]],dp[i]+x[2]); ans=max(ans,dp[i+x[1]]); } } } } cout << ans; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:14:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     freopen("in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
clo.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen("out.txt", "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...