Submission #165389

#TimeUsernameProblemLanguageResultExecution timeMemory
165389LawlietCloud Computing (CEOI18_clo)C++14
18 / 100
5 ms1912 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long int lli; const int MAXN = 300; int n, m; lli dp[MAXN][MAXN]; vector< pii > buy; vector< pii > sell; lli solve(int i, int j) { if( i < 0 || j < 0 ) return 0; lli& ans = dp[i][j]; if( ans != -1 ) return ans; ans = max( solve( i - 1 , j ) , solve( i , j - 1 ) ); if( buy[i].first >= sell[j].first ) { lli cost = sell[j].second - buy[i].second; ans = max( ans , solve( i - 1 , j - 1 ) + cost ); } ans = max( ans , 0LL ); return ans; } int main() { scanf("%d",&n); for(int i = 1 ; i <= n ; i++) { int c, f, v; scanf("%d %d %d",&c,&f,&v); buy.push_back( { f , v } ); } scanf("%d",&m); for(int i = 1 ; i <= m ; i++) { int c, f, v; scanf("%d %d %d",&c,&f,&v); sell.push_back( { f , v } ); } memset( dp , -1 , sizeof(dp) ); sort(buy.begin() , buy.end()); sort(sell.begin() , sell.end()); printf("%lld\n",solve( n - 1 , m - 1 )); }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:39:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
  ~~~~~^~~~~~~~~
clo.cpp:44:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&c,&f,&v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
clo.cpp:49:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&m);
  ~~~~~^~~~~~~~~
clo.cpp:54:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d",&c,&f,&v);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
#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...