Submission #763643

#TimeUsernameProblemLanguageResultExecution timeMemory
763643vjudge1Cloud Computing (CEOI18_clo)C++17
100 / 100
238 ms2152 KiB
#include <cstdio> #include <cstring> #include <algorithm> #define int long long const int maxn = (int) 2e5 + 5; struct node { int c, f, v; bool data; } a[4005]; int C, n, m, num, ans, dp[maxn]; bool cmp(node x, node y) { if(x.f != y.f) return x.f > y.f; if(x.data != y.data) return x.data < y.data; if(!x.data) return x.v < y.v; return x.v > y.v; } signed main() { memset(dp, -0x3f, sizeof(dp)); dp[0] = 0; scanf("%lld", &n); for(int i = 1; i <= n; i++) { scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[i].v); a[i].data = 0; } scanf("%lld", &m); for(int i = n + 1; i <= n + m; i++) { scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[i].v); a[i].data = 1; } num = m + n; std :: stable_sort(a + 1, a + num + 1, cmp); /* for(int i = 1; i <= num; i++) printf("%d %d %d %d\n", a[i].c, a[i].f, a[i].v, a[i].data); */ for(int i = 1; i <= num; i++) { if(!a[i].data) { // 计算机 C += a[i].c; for(int j = C; j >= a[i].c; j--) dp[j] = std :: max(dp[j], dp[j - a[i].c] - a[i].v); } else { // 客户 for(int j = 0; j <= C - a[i].c; j++) dp[j] = std :: max(dp[j], dp[j + a[i].c] + a[i].v); } } for(int i = 0; i <= C; i++) ans = std :: max(ans, dp[i]); printf("%lld", ans); return 0; }

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%lld", &n);
      |  ~~~~~^~~~~~~~~~~~
clo.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[i].v);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%lld", &m);
      |  ~~~~~^~~~~~~~~~~~
clo.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |   scanf("%lld %lld %lld", &a[i].c, &a[i].f, &a[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...