Submission #1033508

#TimeUsernameProblemLanguageResultExecution timeMemory
1033508warrennCloud Computing (CEOI18_clo)C++14
0 / 100
2045 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define int long long bool cmp(tuple<int,int,int,int>q,tuple<int,int,int,int>w ){ auto &[a,b,c,type]=q; auto &[d,e,f,tipe]=w; if(b!=e){ return b<e; } else{ return type>tipe; } } signed main(){ int n; cin>>n; vector<tuple<int,int,int,int> > barang; int sum=0; for(int q=1;q<=n;q++){ int a,b,c; cin>>a>>b>>c; barang.push_back({a,b,c,0}); sum+=b; } int m; cin>>m; for(int q=1;q<=m;q++){ int a,b,c; cin>>a>>b>>c; barang.push_back({a,b,c,1}); } sort(barang.begin(),barang.end(),cmp); int dp[sum+1]; for(int q=0;q<=sum;q++){ dp[q]=-1e15; } dp[0]=0; for(int q=n+m;q>=1;q--){ auto [a,b,c,tipe]=barang[q-1]; if(tipe==0){ for(int e=sum;e>=a;e--){ dp[e]=max(dp[e],dp[e-a]-c); } } else{ for(int e=0;e+a<=sum;e++){ dp[e]=max(dp[e],dp[e+a]+c); } } } int ans=-1e18; for(int q=0;q<=sum;q++){ ans=max(ans,dp[q]); } cout<<ans<<endl; }

Compilation message (stderr)

clo.cpp: In function 'bool cmp(std::tuple<long long int, long long int, long long int, long long int>, std::tuple<long long int, long long int, long long int, long long int>)':
clo.cpp:6:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
    6 |     auto &[a,b,c,type]=q;
      |           ^
clo.cpp:7:11: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
    7 |     auto &[d,e,f,tipe]=w;
      |           ^
clo.cpp: In function 'int main()':
clo.cpp:43:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   43 |         auto [a,b,c,tipe]=barang[q-1];
      |              ^
#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...