Submission #1111244

#TimeUsernameProblemLanguageResultExecution timeMemory
1111244KALARRYCloud Computing (CEOI18_clo)C++14
0 / 100
2683 ms262144 KiB
//chockolateman #include<bits/stdc++.h> using namespace std; long long N,M,dp[255][255][255]; //dp[i][j][x] = max_profit if for first i profit and first j orders and purchasing x offers >= f[j] struct Offer { long long c,f,v; bool operator < (const Offer &Other) { return f < Other.f; } }offers[2005]; struct Order { long long c,f,v; bool operator < (const Order &Other) { return f < Other.f; } }orders[2005]; int main() { scanf("%lld",&N); long long total = 0; for(long long c,f,v,i = 1 ; i <= N ; i++) { scanf("%lld%lld%lld",&c,&f,&v); offers[i] = {c,f,v}; total += c; } scanf("%lld",&M); for(long long c,f,v,i = 1 ; i <= M ; i++) { scanf("%lld%lld%lld",&c,&f,&v); orders[i] = {c,f,v}; } sort(offers+1,offers+N+1); sort(orders+1,orders+M+1); for(long long j = 1 ; j <= M ; j++) for(long long x = 0 ; x <= total ; x++) { dp[0][j][x] = dp[0][j-1][x]; if(x >= orders[j].c) dp[0][j][x] = max(dp[0][j][x],dp[0][j-1][x - orders[j].c] + orders[j].v); } for(long long i = 1 ; i <= N ; i++) for(long long j = 1 ; j <= M ; j++) for(long long x = 0 ; x <= total ; x++) { dp[i][j][x] = max(dp[i-1][j][x],dp[i][j-1][x]); if(offers[i].f >= orders[j].f) dp[i][j][x] = max(dp[i][j][x],dp[i-1][j][x + offers[i].c] - offers[i].v); } printf("%lld\n",dp[N][M][0]); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:29:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |     scanf("%lld",&N);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:33:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |         scanf("%lld%lld%lld",&c,&f,&v);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     scanf("%lld",&M);
      |     ~~~~~^~~~~~~~~~~
clo.cpp:40:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |         scanf("%lld%lld%lld",&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...