Submission #940138

#TimeUsernameProblemLanguageResultExecution timeMemory
940138vjudge1Cloud Computing (CEOI18_clo)C++17
100 / 100
584 ms2388 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define ll long long #define int long long const int N=1e5+5,INF=1e18; void solve(){ int n;cin>>n; vector<pair<int,pair<int,int>>> a; for(int i=0;i<n;i++){ int c,f,v;cin>>c>>f>>v; a.pb({f,{c,-v}}); } int m;cin>>m; for(int i=0;i<m;i++){ int c,f,v;cin>>c>>f>>v; a.pb({f,{-c,v}}); } sort(rall(a)); vector<int> dp(N,-INF),dp1(N,-INF); dp1[0]=0; dp[0]=0; for(int i=0;i<(int)a.size();i++){ //dp=dp1; for(int j=0;j<N;j++){ int k=j+a[i].sc.fr; if(k<0 || k>=N) continue; dp[k]=max(dp[k],dp1[j]+a[i].sc.sc); } dp1=dp; } cout<<*max_element(all(dp)); } main(){ int T=1; //cin>>T; while(T--){ solve(); } } /* 12 2 2 3 3 8 1 5 6 7 8 3 5 4 2 1 2 7 3 4 4 7 7 6 5 6 6 8 6 9 7 10 10 11 10 12 */

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...