Submission #384283

#TimeUsernameProblemLanguageResultExecution timeMemory
384283rumen_mCloud Computing (CEOI18_clo)C++17
18 / 100
958 ms2156 KiB
# include <bits/stdc++.h> using namespace std; const int maxn = 5005; struct query { int idx; int c,f,v; }; query q[maxn]; query comp[maxn]; bool gett[maxn]; long long cores[200005][2]; bool cmp(query i, query j) { if(i.f==j.f) { return i.v<j.v; } return i.f>j.f; } int SUM = 0; int n,m; void solve() { int i,j; int maxs= n*50; for(i=1;i<=maxs;i++) cores[i][0] = -1e18; cores[0][0] = 0; bool fl = 1; for(i=1;i<=n+m;i++) { // cout<<q[i].c<<" "<<q[i].f<<" "<<q[i].v<<endl; for(j=0;j<=maxs;j++) { cores[j][fl] = -1e18; if(j==0)cores[j][fl]=0; if((j-q[i].c)>=0&&(j-q[i].c)<=maxs) { cores[j][fl] = max(cores[j][fl],max(cores[j][!fl],cores[j-q[i].c][!fl]+q[i].v)); } //cout<<j<<" -> "<<cores[j][fl]<<endl; } fl=!fl; } long long ans = -1e18; for(i=0;i<=maxs;i++) { ans = max(ans,cores[i][!fl]); } cout<<ans<<endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int i,j; cin>>n; for(i=1;i<=n;i++) { cin>>q[i].c>>q[i].f>>q[i].v; q[i].v = -q[i].v; } cin>>m; for(i=1;i<=m;i++) { cin>>q[n+i].c>>q[n+i].f>>q[n+i].v; q[n+i].c = -q[n+i].c; } sort(q+1,q+m+n+1,cmp); //cout<<"OK"<<endl; solve(); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:59:11: warning: unused variable 'j' [-Wunused-variable]
   59 |     int i,j;
      |           ^
#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...