Submission #827560

#TimeUsernameProblemLanguageResultExecution timeMemory
827560gagik_2007Cloud Computing (CEOI18_clo)C++17
100 / 100
590 ms2132 KiB
#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; }

Compilation message (stderr)

clo.cpp: In constructor 'Point::Point(int, int, int, bool)':
clo.cpp:19:13: warning: 'Point::v' will be initialized after [-Wreorder]
   19 |     int f,c,v;
      |             ^
clo.cpp:18:10: warning:   'bool Point::is_order' [-Wreorder]
   18 |     bool is_order;
      |          ^~~~~~~~
clo.cpp:20:5: warning:   when initialized here [-Wreorder]
   20 |     Point(int fff, int cc, int vv, bool b):f(fff),c(cc),v(vv),is_order(b){}
      |     ^~~~~
clo.cpp: In function 'int main()':
clo.cpp:56:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Point>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
#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...