Submission #368100

#TimeUsernameProblemLanguageResultExecution timeMemory
368100ogibogi2004Cloud Computing (CEOI18_clo)C++14
100 / 100
435 ms1516 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long const ll MAXN=1e5+6; const ll INF=1e17; struct event { int c,f,v; int type; bool operator<(event const& other)const { if(f!=other.f)return f>other.f; if(type!=other.type)return type==1; return v<other.v; } }; vector<event>e; ll dp[MAXN]; ll n,m; void solve() { cin>>n; for(int i=0;i<n;i++) { int x,y,z; cin>>x>>y>>z; e.push_back({x,y,z,1}); } cin>>m; for(int i=0;i<m;i++) { int x,y,z; cin>>x>>y>>z; e.push_back({x,y,z,-1}); } sort(e.begin(),e.end()); for(int i=1;i<MAXN;i++)dp[i]=-INF; for(int i=0;i<e.size();i++) { if(e[i].type==1) { for(int j=MAXN-e[i].c-1;j>=0;j--) { dp[j+e[i].c]=max(dp[j+e[i].c],dp[j]-e[i].v); } } else { for(int j=e[i].c;j<MAXN;j++) { dp[j-e[i].c]=max(dp[j-e[i].c],dp[j]+e[i].v); } } } ll ans=-INF; for(int i=0;i<MAXN;i++) { ans=max(ans,dp[i]); } cout<<ans<<endl; } int main() { solve(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'void solve()':
clo.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<event>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |  for(int i=0;i<e.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...