Submission #564996

#TimeUsernameProblemLanguageResultExecution timeMemory
564996KarukCloud Computing (CEOI18_clo)C++14
18 / 100
347 ms262144 KiB
#include<bits/stdc++.h> #define min(A,B) (A<B?A:B) #define max(A,B) (A>B?A:B) using namespace std; vector<long long>dp[4001]; void solve() { int n; cin>>n; vector<vector<int> >a; for(int i=0;i<n;i++) { int f,v,c; cin>>c>>f>>v; a.push_back({f,c,-v}); } int m; cin>>m; for(int i=0;i<m;i++) { int f,v,c; cin>>c>>f>>v; a.push_back({f,-c,v}); } sort(a.begin(),a.end()); dp[0]=vector<long long>(51,0); for(int i=1;i<=n+m;i++) { int maxs=min(100000,50+50*min(i,n+m-i)); dp[i]=vector<long long>(maxs+1,-(1e14)); for(int negcores=0;negcores<=maxs;negcores++) { if(negcores<dp[i-1].size())dp[i][negcores]=max(dp[i][negcores],dp[i-1][negcores]); if(negcores+a[i-1][1]>=0 && negcores+a[i-1][1]<dp[i-1].size()) dp[i][negcores]=max(dp[i][negcores],dp[i-1][negcores+a[i-1][1]]+a[i-1][2]); } } cout<<dp[n+m][0]<<endl; } int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); solve(); return 0; }

Compilation message (stderr)

clo.cpp: In function 'void solve()':
clo.cpp:28:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if(negcores<dp[i-1].size())dp[i][negcores]=max(dp[i][negcores],dp[i-1][negcores]);
      |                ~~~~~~~~^~~~~~~~~~~~~~~
clo.cpp:29:59: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |             if(negcores+a[i-1][1]>=0 && negcores+a[i-1][1]<dp[i-1].size())
      |                                         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#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...