제출 #217589

#제출 시각아이디문제언어결과실행 시간메모리
217589DystoriaXCloud Computing (CEOI18_clo)C++14
0 / 100
50 ms560 KiB
#include <bits/stdc++.h> using namespace std; struct node{ int c, f, v; }; int n, m; const int MAX = 10010; vector<node> comp, dem; priority_queue<int, vector<int>, greater<int> > pq; long long ans = 0, dp[MAX], dps[MAX]; bool cp(node a, node b){ return a.f > b.f; } int main(){ scanf("%d", &n); comp.resize(n + 1); for(int i = 1; i <= n; i++) scanf("%d%d%d", &comp[i].c, &comp[i].f, &comp[i].v); scanf("%d", &m); dem.resize(m + 1); for(int i = 1; i <= m; i++) scanf("%d%d%d", &dem[i].c, &dem[i].f, &dem[i].v); sort(comp.begin() + 1, comp.end(), cp); sort(dem.begin() + 1, dem.end(), cp); //dp = minCost, maxProfit for(int i = 0; i < MAX; i++) dp[i] = 1e18; dp[0] = 0; for(int i = 1; i <= n; i++) for(int k = MAX - 1; k >= comp[i].c; k--) dp[k] = min(dp[k], dp[k - comp[i].c] + comp[i].v); for(int i = 1; i <= m; i++) for(int k = MAX - 1; k >= dem[i].c; k--) dps[k] = max(dps[k], dps[k - dem[i].c] + dem[i].v); for(int i = MAX - 2; i; i--) dp[i] = min(dp[i], dp[i + 1]); for(int i = 1; i < MAX; i++) dps[i] = max(dps[i], dps[i - 1]); for(int i = 0; i < MAX; i++) ans = max(ans, dps[i] - dp[i]); printf("%lld\n", ans); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

clo.cpp: In function 'int main()':
clo.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
clo.cpp:23:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= n; i++) scanf("%d%d%d", &comp[i].c, &comp[i].f, &comp[i].v);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
clo.cpp:28:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 1; i <= m; i++) scanf("%d%d%d", &dem[i].c, &dem[i].f, &dem[i].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...