Submission #997387

#TimeUsernameProblemLanguageResultExecution timeMemory
997387daffuwuCloud Computing (CEOI18_clo)C++14
100 / 100
431 ms2140 KiB
#include <bits/stdc++.h> using namespace std; #define fr first #define sc second mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); long long n, m, dp[2][100069]; //{komp sekarang, order sekarang, core tersisa komp, needed core order} struct machine { long long c, f, v; bool operator<(const machine other) const { if (f == other.f) return c>other.c; return f<other.f; } } a[4069]; int main() { long long i, j; scanf("%lld", &n); for (i=1; i<=n; i++) { scanf("%lld%lld%lld", &a[i].c, &a[i].f, &a[i].v); a[i].c *= -1; a[i].v *= -1; } scanf("%lld", &m); for (i=1; i<=m; i++) { scanf("%lld%lld%lld", &a[n+i].c, &a[n+i].f, &a[n+i].v); } sort(a+1, a+n+m+1); //dp[i][j] --> max uang kalau total core adalah j for (j=1; j<=100000; j++) dp[(n+m+1)%2][j] = -1e15; for (i=n+m; i>=1; i--) { for (j=0; j<=100000; j++) { dp[i%2][j] = dp[(i+1)%2][j]; if (j+a[i].c<=100000) dp[i%2][j] = max(dp[i%2][j], dp[(i+1)%2][max(0ll, j+a[i].c)]+a[i].v); } } printf("%lld\n", dp[1][0]); }

Compilation message (stderr)

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