Submission #956486

#TimeUsernameProblemLanguageResultExecution timeMemory
956486modwweCloud Computing (CEOI18_clo)C++17
100 / 100
235 ms4200 KiB
#include<bits/stdc++.h> #define int long long #define down cout<<'\n'; #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back using namespace std; void phongbeo(); mt19937 rd(chrono::high_resolution_clock::now().time_since_epoch().count ()); const int mod2=1e9+7; const int mod1=998244353; struct ib { int a; int b; }; struct icd { int a,b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; int minn=1e12+1,maxx=-1e9; int n,m,s2,s4,s3,sf,k,r,dem=0,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,l; int s,i,s10,s12; int el=29; main() { #ifndef ONLINE_JUDGE //fin(task),fou(task); #endif NHP //modwwe phongbeo(),down } bool cmp(ic a,ic b) { return a.b<b.b; } int dp[200001]; ic a[100001]; ic b[100001]; void phongbeo() { cin>>n; for(int i=1;i<=n;i++) cin>>a[i].a>>a[i].b>>a[i].c,s5=max(s5,a[i].a),s7+=a[i].a; cin>>m; for(int i=1;i<=m;i++) cin>>b[i].a>>b[i].b>>b[i].c,s7+=b[i].a; sort(a+1,a+1+n,cmp); sort(b+1,b+1+m,cmp); s2=m; for(int i=1;i<=s7;i++) dp[i]=-1e18; for(int i=n;i>=0;--i) { s6+=a[i].a; while(s2>=1&&b[s2].b>a[i].b){ s2--; // cout<<dp[2]<<" "<<b[s2].a<<" "<<dp[5]<<" "<<b[s2].c,down if(b[s2].b>a[i].b&&s2!=0) for(int j=b[s2].a;j<=s6;j++) dp[j-b[s2].a]=max(dp[j-b[s2].a],dp[j]+b[s2].c); } if(i==0) break; for(int j=s6;j>=0;j--){ dp[j+a[i].a]=max(dp[j+a[i].a],dp[j]-a[i].c); } if(i!=0) if(b[s2].b>a[i-1].b) for(int j=b[s2].a;j<=s6;j++){ dp[j-b[s2].a]=max(dp[j-b[s2].a],dp[j]+b[s2].c); } //cout<<dp[7]<<" "<<i<<" "<<s2<<" "<<b[s2].a<<" "<<b[s2].c,down } s4=0; for(int j=0;j<=s6;j++){ s4=max(s4,dp[j]); // cout<<dp[j]<<" "<<j,down } cout<<s4; }

Compilation message (stderr)

clo.cpp:38:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   38 | main()
      | ^~~~
#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...